@wordpress/components package provides a library of generic WordPress components for creating common UI elements shared between screens and features of the WordPress dashboard.
Installation
Install the package using npm:This package assumes that your code will run in an ES2015+ environment. If you’re using an environment with limited support for such language features, include the polyfill shipped in
@wordpress/babel-preset-default.Basic Usage
You can import components from the package root:Styling Components
Many components include CSS to add styles. You need to load these styles for components to appear correctly.In WordPress
Add thewp-components stylesheet as a dependency of your plugin’s stylesheet:
Outside WordPress
Link directly to the built stylesheet:TypeScript Support
This package exports types for the components it provides. Extract props types usingReact.ComponentProps:
Working with Popovers
By default, thePopover component renders within an extra element appended to the document body. You can control where popovers render using Popover.Slot:
Key Components
Button
Clickable buttons for triggering actions
TextControl
Standard text input fields
SelectControl
Dropdown select menus
CheckboxControl
Checkbox inputs with labels
Panel
Collapsible panels for organizing content
Modal
Dialog modals for focused interactions
Form Components
If you’re building a form to edit items in a dataset (rather than simply submitting data), consider using
DataForm from the @wordpress/dataviews package.For adding validation, use the Validated Form Components.Component Status
Documentation & Examples
Browse the complete component library with interactive examples: View Storybook Documentation →Peer Dependencies
This package requires React as a peer dependency:Related Packages
@wordpress/compose- Higher-order components and hooks used by components@wordpress/element- React abstraction layer@wordpress/icons- Icon library used in components