-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add README for WritingModeControl component
- Loading branch information
1 parent
b226cee
commit 2ab583a
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
packages/block-editor/src/components/writing-mode-control/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# WritingModeControl | ||
|
||
WritingModeControl is a React component that renders a UI that allows users to select text orientation (writing mode). | ||
The component provides a toggle group interface that allows users to switch between horizontal and vertical text orientations, with automatic RTL (Right-to-Left) support. | ||
|
||
## Usage | ||
|
||
```jsx | ||
import { WritingModeControl } from '@wordpress/block-editor'; | ||
import { useState } from '@wordpress/element'; | ||
|
||
const MyWritingModeControl = () => { | ||
const [ writingMode, setWritingMode ] = useState(); | ||
|
||
return ( | ||
<WritingModeControl | ||
value={ writingMode } | ||
onChange={ ( newWritingMode ) => { | ||
setWritingMode( newWritingMode ); | ||
} } | ||
/> | ||
); | ||
}; | ||
``` | ||
|
||
## Props | ||
|
||
The component accepts the following props: | ||
|
||
### onChange | ||
|
||
A function that handles change in the writing mode selection. | ||
|
||
- Type: `function` | ||
- Required: Yes | ||
|
||
### value | ||
|
||
The current writing mode value. Can be one of: | ||
- `'horizontal-tb'` - Horizontal top-to-bottom text | ||
- `'vertical-rl'` - Vertical right-to-left text (for LTR languages) | ||
- `'vertical-lr'` - Vertical left-to-right text (for RTL languages) | ||
|
||
- Type: `string` | ||
- Required: No | ||
- Default: `undefined` | ||
|
||
### className | ||
|
||
Additional class name to add to the control. | ||
|
||
- Type: `string` | ||
- Required: No |