The BlockAlignmentToolbar
component is used to render block alignment options in the editor. The different alignment options it provides are left
, center
, right
, wide
and full
.
Renders a block alignment toolbar with alignments options.
import { BlockAlignmentToolbar } from '@wordpress/block-editor';
const MyBlockAlignmentToolbar = () => (
<BlockControls>
<BlockAlignmentToolbar value={ align } onChange={ updateAlignment } />
</BlockControls>
);
Note: In this example that we render BlockAlignmentToolbar
as a child of the BlockControls
component.
- Type:
String
- Default:
undefined
- Options::
left
,center
,right
,wide
,full
The current value of the alignment setting. You may only choose from the Options
listed above.
- Type:
Function
A callback function invoked when the toolbar's alignment value is changed via an interaction with any of the toolbar's buttons. Called with the new alignment value (ie: left
, center
, right
, wide
, full
) as the only argument.
Block Editor components are components that can be used to compose the UI of your block editor. Thus, they can only be used under a BlockEditorProvider
in the components tree.