@wordpress/block-editor package provides React components and hooks for creating standalone block editors. Itβs WordPress-agnostic and can be used to build custom editing experiences.
Installation
Basic Usage
Core Components
BlockEditorProvider
Provides block editor context to child components.BlockCanvas
Renders the block editor canvas in an iframe.height(string) - Canvas height (default: β300pxβ)styles(Array) - Content styles to injectchildren(Element) - Custom canvas content
BlockList
Renders the list of blocks.BlockInspector
Displays block settings sidebar.BlockToolbar
Renders the block toolbar with formatting controls.Block Controls
BlockControls
Adds controls to the block toolbar.InspectorControls
Adds controls to the block settings sidebar.Rich Text
RichText
Editable rich text component.PlainText
Plain text area for code or simple text.Hooks
useBlockProps
Marks an element as a block. Required for API v2+.useInnerBlocksProps
Marks an element as an inner blocks container.useBlockEditContext
Retrieves information about the current block.Color and Typography
ColorPalette
Color picker with theme colors.FontSizePicker
Font size selector.Media
MediaPlaceholder
Media upload placeholder.MediaReplaceFlow
Media replacement controls.Layout and Alignment
AlignmentControl
Text alignment toolbar.BlockAlignmentControl
Block alignment toolbar.Utilities
getColorObjectByColorValue
Finds a color object by value.getFontSize
Retrieves font size information.Store
Access the block editor store:Important Notes
- This package is WordPress-agnostic - avoid adding WordPress-specific dependencies
- Always use
useBlockPropsfor the outermost element in block edit functions - Load required stylesheets:
@wordpress/block-editor/build-style/style.css - Register block types before using the editor