Textarea
A multi-line text input with Fluent styling (resize vertical by default, accessible bottom stroke, primary bottom border while focused). Inside a Field it picks up the label, hint, error, required (native attribute) and invalid state automatically.
size resolves from its own prop, then the surrounding Field's size, then WaveProvider inputDefaults.size, else 'medium'; appearance from its own prop, then WaveProvider inputDefaults.appearance, else 'outline'; both render as data-size and data-appearance on the textarea element.
Examples
Default
export const Default: Story = {};Error
export const Error: Story = {
args: {
'aria-label': 'Description',
placeholder: 'Description',
error: 'Description is required',
},
};Disabled
export const Disabled: Story = {
args: {
placeholder: 'Disabled',
disabled: true,
},
};Sizes And Appearances
export const SizesAndAppearances: Story = {
render: (args) => (
<SizeAppearanceGrid
render={(size, appearance) => (
<Textarea
{...args}
rows={2}
size={size}
appearance={appearance}
aria-label={`${size} ${appearance}`}
/>
)}
/>
),
};Resize
export const Resize: Story = {
render: (args) => (
<div className="flex flex-col gap-4">
{(['none', 'vertical', 'horizontal', 'both'] as const).map((resize) => (
<Textarea {...args} key={resize} rows={2} resize={resize} aria-label={`resize ${resize}`} />
))}
</div>
),
};Controlled
export const Controlled: Story = {
render: function Render(args) {
const [value, setValue] = useState('');
return (
<div className="flex flex-col gap-2">
<Textarea {...args} value={value} onValueChange={setValue} />
<span className="text-wave-caption-1 text-wave-muted-foreground">
{value.length} characters
</span>
</div>
);
},
};Props
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
error | string | boolean | No | Validation error. The error border also shows whenever the textarea ends up | |
errorMessageProps | InputErrorMessageProps | No | Props of the error message element ( | |
size | 'small' | 'medium' | 'large' | No | Size of the field, a minimum height with its type ramp: | |
appearance | 'outline' | 'underline' | 'filled-darker' | 'filled-lighter' | No | Look of the field: | |
resize | 'none' | 'vertical' | 'horizontal' | 'both' | No | 'vertical' | Which directions the user can drag the corner handle to resize the field in (Fluent UI's |
onValueChange | (value: string) => void | No | Called with the new string value on every change, next to the native | |
ref | React.Ref<HTMLTextAreaElement> | No | Ref to the |
Any other prop is passed to the element it renders (HTMLTextAreaElement).
Stable class names
| Part | Class |
|---|---|
root | wave-textarea |
errorMessage | wave-textarea__error-message |