@wordpress/block-editor
Version:
76 lines (50 loc) • 1.73 kB
Markdown
# Alignment Matrix Control
The alignment matrix control allows users to quickly adjust inner block alignment; this is in contrast to the alignment toolbar that aligns the frame block.

## Design guidelines
### Usage
The alignment matrix is a specialized tool, and it's used in the cover block.

As an example, here's the matrix alignment tool in action.


## Development guidelines
### Usage
```jsx
// This is a paraphrased example from the cover block
import {
BlockControls,
__experimentalBlockAlignmentMatrixControl as BlockAlignmentMatrixControl
} from "@wordpress/block-editor";
const controls = (
<>
<BlockControls>
<BlockAlignmentMatrixControl
label={ __( 'Change content position' ) }
value={ contentPosition }
onChange={ ( nextPosition ) =>
setAttributes( { contentPosition: nextPosition } )
}
/>
</BlockControls>
</>
);
```
### Props
### `label`
- **Type:** `string`
- **Default:** `'Change matrix alignment'`
Label for the control.
### `onChange`
- **Type:** `Function`
- **Default:** `noop`
Function to execute upon a user's change of the matrix state.
### `value`
- **Type:** `string`
- **Default:** `'center'`
- **Options:** `'center'`, `'center center'`, `'center left'`, `'center right'`, `'top center'`, `'top left'`, `'top right'`, `'bottom center'`, `'bottom left'`, `'bottom right'`
Content alignment location.
### `isDisabled`
- **Type:** `boolean`
- **Default:** `false`
Whether the control should be disabled.