A low-level primitive for a textarea field.
Prefer TextareaControl when using with a standard label and description.
import { Textarea } from '@wordpress/ui';
LinksPermalink to this section
PropsPermalink to this section
| Name | Default | Description |
|---|---|---|
render |
Replaces the component’s default HTML element using a given React element, or a function that returns a React element. | |
style |
CSS style to apply to the element. | |
className |
CSS class name to apply to the element. | |
defaultValue |
The default value to use in uncontrolled mode. | |
disabled |
Whether the field is disabled. | |
value |
The value to use in controlled mode. | |
onValueChange |
Callback fired when the | |
rows | 4 |
The number of rows the textarea should contain. |
ExamplesPermalink to this section
DefaultPermalink to this section
const Default = () => <Textarea placeholder="Placeholder" aria-label="Value" />;
DisabledPermalink to this section
const Disabled = () => <Textarea disabled />;
With OverflowPermalink to this section
const WithOverflow = () => <Textarea
defaultValue={`Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.`} />;
With One RowPermalink to this section
When rows is set to 1, the textarea will have the same footprint as a default Input.
const WithOneRow = () => <Textarea rows={1} />;