Skip to main content
Version: Next

Textarea

A multi-line text input with autosize, character counter, debounced input, and clearable support. Uses a composed pattern — Textarea.Label, Textarea.Description, and Textarea.Error map to the web component's named slots.

Import

import { Textarea } from '@editora/ui-react';
// or subpath
import { Textarea } from '@editora/ui-react/Textarea';

Basic Usage

<Textarea
placeholder="Write a release summary..."
rows={4}
onChange={(value) => console.log(value)}
/>

With Label and Description

<Textarea
placeholder="Describe what changed and why..."
rows={4}
>
<Textarea.Label>Change reason</Textarea.Label>
<Textarea.Description>Required for audit trails.</Textarea.Description>
</Textarea>

With Error

<Textarea validation="error" value="">
<Textarea.Label>Change reason</Textarea.Label>
<Textarea.Error>Please provide a reason before publishing.</Textarea.Error>
</Textarea>

Controlled with Debounce

const [value, setValue] = useState('');
const [debounced, setDebounced] = useState('');

<Textarea
value={value}
debounce={320}
clearable
rows={5}
variant="soft"
onInput={setValue}
onDebouncedInput={setDebounced}
>
<Textarea.Label>Release notes</Textarea.Label>
<Textarea.Description>Debounced output updates after 320ms.</Textarea.Description>
</Textarea>

Autosize with Counter

<Textarea
autosize
maxRows={8}
rows={3}
showCount
maxlength={600}
variant="filled"
tone="success"
placeholder="Add operational context..."
>
<Textarea.Label>Internal context</Textarea.Label>
<Textarea.Description>Grows up to 8 rows automatically.</Textarea.Description>
</Textarea>

Props

Textarea (root)

PropTypeDefaultDescription
valuestringControlled value
placeholderstringPlaceholder text
rowsnumber4Initial visible row count
minlengthnumberMinimum character length
maxlengthnumberMaximum character length
clearablebooleanfalseShows a clear button when field has value
showCountbooleanfalseShows character count (and max if maxlength is set)
autosizebooleanfalseGrows height to fit content
maxRowsnumberMaximum rows when autosize is enabled
debouncenumberDebounce delay in ms for onDebouncedInput
validation'error' | 'success' | 'none''none'Visual validation state
variant'classic' | 'surface' | 'soft' | 'filled' | 'ghost' | 'contrast''classic'Visual style
size'sm' | 'md' | 'lg' | '1' | '2' | '3''md'Field size
density'compact' | 'default' | 'comfortable''default'Vertical padding density
tone'brand' | 'success' | 'warning' | 'danger''brand'Accent color
resize'none' | 'both' | 'horizontal' | 'vertical''vertical'CSS resize handle
radius'none' | 'large' | 'full' | stringBorder radius override
disabledbooleanfalseDisables the field
readOnlybooleanfalseMakes the field read-only
requiredbooleanfalseMarks field as required
autofocusbooleanfalseFocuses field on mount
namestringForm field name
labelstringShorthand label (alternative to Textarea.Label)
descriptionstringShorthand description (alternative to Textarea.Description)
headlessbooleanfalseHides meta and footer, renders bare field only
onChange(value: string) => voidFires on committed change
onInput(value: string) => voidFires on every keystroke
onDebouncedInput(value: string) => voidFires after debounce ms of inactivity
onClear() => voidFires when clear button is clicked

Textarea.Label

PropTypeDescription
childrenReact.ReactNodeLabel text content
...restReact.HTMLAttributes<HTMLElement>Passed to inner <span>

Textarea.Description

PropTypeDescription
childrenReact.ReactNodeDescription text content
...restReact.HTMLAttributes<HTMLElement>Passed to inner <span>

Textarea.Error

PropTypeDescription
childrenReact.ReactNodeError message content
...restReact.HTMLAttributes<HTMLElement>Passed to inner <span>

Notes

  • label/description string props and Textarea.Label/Textarea.Description sub-components are equivalent — use whichever fits your pattern.
  • autosize grows the field height to fit content, capped at maxRows if provided.
  • showCount displays character count; when combined with maxlength it shows n / max format.
  • debounce only affects onDebouncedInputonInput always fires immediately.