@wordpress/components package provides a comprehensive library of generic WordPress components for creating common UI elements shared between screens and features of the WordPress dashboard.
Installation
Basic Usage
Import components from the root directory:This package is currently in transition. Components are being migrated to
@wordpress/ui, but you should continue using @wordpress/components until further notice. Check each component’s Storybook documentation for the most accurate status information.Styling
Most components include CSS styles that must be loaded:Within WordPress
Add thewp-components stylesheet as a dependency:
Outside WordPress
Link directly to the built stylesheet:TypeScript Support
This package exports types for all components. Extract props types usingReact.ComponentProps:
Component Categories
UI Controls
Form inputs and interactive controls for user input:- Button, ButtonGroup
- TextControl, TextareaControl
- ToggleControl, CheckboxControl, RadioControl
- SelectControl, ComboboxControl
- RangeControl, NumberControl
- ColorPicker, DateTimePicker
Layout Components
Containers and layout primitives for organizing content:- Flex, HStack, VStack
- Grid, Spacer
- Panel, PanelBody, PanelRow
- Card, CardHeader, CardBody, CardFooter
Data Display
Components for presenting information:- Spinner
- ProgressBar
- Badge
- Avatar, AvatarGroup
- Icon, Dashicon
Feedback Components
Overlays and notifications for user feedback:- Notice, SnackbarList
- Modal, ConfirmDialog
- Popover, Tooltip
- DropdownMenu
Storybook Documentation
Detailed examples and interactive demos are available in Storybook: https://wordpress.github.io/gutenberg/Component status in Storybook files is the most accurate signal, above any
experimental tag or component prefix.Special Features
Popovers
By default,Popover components render in an extra element appended to the document body. For precise control, use Popover.Slot:
Form Validation
For forms that edit dataset items, consider usingDataForm from @wordpress/dataviews.
For validation, use the Validated Form Components.
Component Status
Due to the ongoing transition to@wordpress/ui, some components may be deprecated or removed. Always:
- Check the component’s Storybook documentation for current status
- Look for
componentStatusmetadata in story files - The Storybook status is more reliable than
experimentalprefixes