Skip to content

Commit

Permalink
doc: Add README.md for text-alignment-control
Browse files Browse the repository at this point in the history
  • Loading branch information
im3dabasia committed Dec 19, 2024
1 parent 1b14b1e commit 5525c9f
Showing 1 changed file with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# TextAlignmentControl

The `TextAlignmentControl` component is responsible for rendering a control element that allows users to select and apply text alignment options to blocks or elements in the Gutenberg editor. It provides an intuitive interface for aligning text with options such as `left`, `center`, `right`, and `justify`.

## Development guidelines

### Usage

Renders the Text Alignment Component with `left`, `center`, `right`, and `justify` alignment options.

```jsx
import { TextAlignmentControl } from '@wordpress/block-editor';

const MyTextAlignmentControlComponent = () => (
<TextAlignmentControl
value={ textAlign }
onChange={ ( value ) => {
setAttributes( { textAlign: value } );
} }
/>
);
```

### Props

### `value`

- **Type:** `String`
- **Default:** `left`
- **Options:** `left`, `center`, `right`, `justify`

The current value of the text alignment setting. You may only choose from the `Options` listed above.

### `onChange`

- **Type:** `Function`

A callback function invoked when the text alignment value is changed via an interaction with any of the options. The function is called with the new alignment value (`left`, `center`, `right`, `justify`) as the only argument.

### `className`

- **Type:** `String`

Class name to add to the control for custom styling.

### `options`

- **Type:** `Array`
- **Default:** [`left`, `center`, `right`]

An array that determines which alignment options will be available in the control. You can pass an array of alignment values to customize the options.

0 comments on commit 5525c9f

Please sign in to comment.