A complete textarea field with integrated label and description.
import { TextareaControl } from '@wordpress/ui';
LinksPermalink to this section
PropsPermalink to this section
| Name | Default | Description |
|---|---|---|
details |
Additional information about the field, which unlike a normal description, can include links and other semantic elements. Do not use this prop when the content is only plain text;
use | |
label Required |
The accessible label. All controls must be labeled. | |
style |
CSS style to apply to the element. | |
disabled |
Whether the field is disabled. | |
value |
The value to use in controlled mode. | |
defaultValue |
The default value to use in uncontrolled mode. | |
className |
CSS class name to apply to the element. | |
description |
The accessible description, associated using For screen reader accessibility, this should only contain plain text, and no semantics such as links. | |
rows | 4 |
The number of rows the textarea should contain. |
render |
Replaces the component’s default HTML element using a given React element, or a function that returns a React element. | |
hideLabelFromVision | false |
Whether to visually hide the label while keeping it accessible to screen readers. |
onValueChange |
Callback fired when the |
ExamplesPermalink to this section
DefaultPermalink to this section
const Default = () => <TextareaControl
label="Label"
description="This is the description."
placeholder="Placeholder" />;
Visually Hidden LabelPermalink to this section
const VisuallyHiddenLabel = () => <TextareaControl hideLabelFromVision />;
With DetailsPermalink to this section
const WithDetails = () => <TextareaControl description={undefined} details={DETAILS_EXAMPLE} />;
ResizePermalink to this section
By default, the textarea is resizable in the vertical direction,
using the resize handle at the bottom right. Although it is possible to modify
or disable this resize behavior through CSS,
we generally do not recommend it, as the default behavior is best for usability in most cases.
const Resize = () => <TextareaControl />;
With OverflowPermalink to this section
const WithOverflow = () => <TextareaControl
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.`} />;
DisabledPermalink to this section
const Disabled = () => <TextareaControl disabled />;