Components
Textarea
Multi-line text fields with token sizes, validation, and native semantics.
Textarea renders a native <textarea> inside the same token-styled field as
Input. It supports the shared control sizes, fixed and auto-resizing
heights, character counts, invalid, disabled, and read-only states, and fills the width of its
container.
Textarea is exported from @orkest/ui/client because it uses client-side state. Render it inside a
Client Component.
Live preview#
import { Box, Caption, Label, Stack } from '@orkest/ui';
import { Textarea } from '@orkest/ui/client';
export function Example() {
return (
<Box style={{ width: '22rem' }}>
<Stack gap={1}>
<Label htmlFor="textarea-message">Message</Label>
<Textarea
id="textarea-message"
rows={4}
placeholder="How can we help?"
aria-describedby="textarea-message-help"
/>
<Caption id="textarea-message-help">Include any relevant details.</Caption>
</Stack>
</Box>
);
}Sizes#
import { Box, Stack } from '@orkest/ui';
import { Textarea } from '@orkest/ui/client';
export function Example() {
return (
<Box style={{ width: '22rem' }}>
<Stack gap={2}>
<Textarea size="sm" rows={3} placeholder="Small" aria-label="Small textarea" />
<Textarea size="md" rows={3} placeholder="Medium" aria-label="Medium textarea" />
<Textarea size="lg" rows={3} placeholder="Large" aria-label="Large textarea" />
<Textarea size="xl" rows={3} placeholder="Extra large" aria-label="Extra large textarea" />
</Stack>
</Box>
);
}Height#
Three modes cover the common cases:
- Fixed — set
rowsandresize="none". - Auto resize — set
autoResizeand the field grows with its content. - Min / max rows — combine
autoResizewithminRowsandmaxRows; extra content scrolls.
import { Box, Stack } from '@orkest/ui';
import { Textarea } from '@orkest/ui/client';
export function Example() {
return (
<Box style={{ width: '22rem' }}>
<Stack gap={3}>
<Textarea rows={4} resize="none" placeholder="Fixed height" aria-label="Fixed height" />
<Textarea
autoResize
rows={2}
defaultValue="Auto resize grows as this content becomes longer."
aria-label="Auto resize"
/>
<Textarea
autoResize
minRows={2}
maxRows={5}
defaultValue="Min and max rows keep the field between two and five visible lines."
aria-label="Bounded rows"
/>
</Stack>
</Box>
);
}resize accepts none, vertical, horizontal, or both. It is ignored when autoResize is
enabled. Regardless of rows, minRows, or auto-resize, the field never shrinks below one line.
Character count#
import { Box } from '@orkest/ui';
import { Textarea } from '@orkest/ui/client';
export function Example() {
return (
<Box style={{ width: '22rem' }}>
<Textarea
showCount
maxLength={120}
rows={4}
placeholder="Tell us about your project"
aria-label="Project details"
/>
</Box>
);
}The count is rendered below the field and updates as the value changes. maxLength remains the
native constraint.
States#
Enter at least 20 characters.
import { Box, Label, Stack, Text } from '@orkest/ui';
import { Textarea } from '@orkest/ui/client';
export function Example() {
return (
<Box style={{ width: '22rem' }}>
<Stack gap={3}>
<Stack gap={1}>
<Label htmlFor="textarea-invalid">Message</Label>
<Textarea
id="textarea-invalid"
invalid
defaultValue="Too short"
aria-describedby="textarea-invalid-error"
/>
<Text as="p" size="sm" tone="danger" id="textarea-invalid-error">
Enter at least 20 characters.
</Text>
</Stack>
<Textarea disabled rows={3} placeholder="Disabled" aria-label="Disabled textarea" />
<Textarea
readOnly
rows={3}
defaultValue="Read-only content"
aria-label="Read-only textarea"
/>
</Stack>
</Box>
);
}Props#
| Prop | Type | Default |
|---|---|---|
size | 'sm' | 'md' | 'lg' | 'xl' | 'md' |
| Padding, radius, and text size. The height follows rows and content. | ||
invalid | boolean | false |
| Applies the danger border and sets aria-invalid. | ||
rows | number | 3 |
| Initial visible line count. | ||
autoResize | boolean | false |
| Grows the textarea with its content and disables manual resize. | ||
minRows | number | — |
| Minimum visible rows when autoResize is enabled. | ||
maxRows | number | — |
| Maximum visible rows when autoResize is enabled; extra content scrolls. | ||
resize | 'none' | 'vertical' | 'horizontal' | 'both' | 'vertical' |
| Manual resize direction. Ignored when autoResize is enabled. | ||
showCount | boolean | false |
| Shows the current character count below the field. | ||
maxLength | number | — |
| Native maximum length. Used by the character count when showCount is enabled. | ||
native attributes | TextareaHTMLAttributes<HTMLTextAreaElement> | — |
| Placeholder, value, name, required, aria-describedby, events, and ref are forwarded. The native numeric size attribute is replaced by the control size. | ||
Textarea fills its container width. Manual resize is vertical by default; use autoResize for
content-driven height.
Accessibility#
- Provide an accessible name with
Label htmlFororaria-label. A placeholder is not a label. - Connect help and error text with
aria-describedby. invalidsetsaria-invalid. Pair it with visible error text; do not rely on the border color alone.disabledandreadOnlyuse the native attributes and remain distinguishable without color alone.- Auto-resize and manual resize change presentation only; value and semantics are unchanged.
- The character count is supplementary.
maxLengthremains the native constraint. - Focus is shown by darkening the field border; no separate focus ring is drawn. Invalid fields keep the danger border.
- Refs are forwarded to the native textarea element.
Related#
- Input for single-line fields.
- Typography for Label, Caption, and error text.
- Button for form actions.