Forms
Textarea
Free11.7 KB gzippedMulti-line text field. Works standalone or inside a Field, which wires the id, label, hint, error, required, disabled, and size automatically.
Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · Keys: Tab · Full report
Import
import { Textarea } from "@vjdesigns/vjdesigns-ui";
Importing only Textarea adds about 11.7 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.
Examples
Auto resize
autoResize grows the field with its content, between minRows and maxRows.
import { Field, Textarea } from "@vjdesigns/vjdesigns-ui";
export function AutoResize() {
return (
<div style={{ width: "100%", maxWidth: "26rem" }}>
<Field label="Message">
<Textarea autoResize minRows={2} maxRows={8} placeholder="Write a message…" />
</Field>
</div>
);
}
Character count
showCount with maxLength shows a live character counter.
import { Field, Textarea } from "@vjdesigns/vjdesigns-ui";
export function CharacterCount() {
return (
<div style={{ width: "100%", maxWidth: "26rem" }}>
<Field label="Short bio">
<Textarea showCount maxLength={160} rows={3} defaultValue="Designer and developer building accessible products." />
</Field>
</div>
);
}
Variants
import { Stack, Textarea } from "@vjdesigns/vjdesigns-ui";
export function Variants() {
return (
<Stack gap={3} style={{ width: "100%", maxWidth: "26rem" }}>
<Textarea aria-label="Outline" rows={2} placeholder="Outline (default)" />
<Textarea aria-label="Filled" rows={2} variant="filled" placeholder="Filled" />
<Textarea aria-label="Invalid" rows={2} invalid defaultValue="Something's wrong here" />
</Stack>
);
}
Accessibility
showCount (with maxLength) links an "n / max" counter to the textarea with aria-describedby. Remaining characters are announced politely only once 90% of the limit is used, so typing isn't drowned out by announcements.
Gate codes, or a safe place to leave the parcel.
import { Field, Textarea } from "@vjdesigns/vjdesigns-ui";
export function Accessibility() {
return (
<div style={{ width: "100%", maxWidth: "28rem" }}>
<Field label="Delivery instructions" hint="Gate codes, or a safe place to leave the parcel.">
<Textarea
maxLength={120}
showCount
autoResize
minRows={3}
defaultValue="Leave it with the neighbor at number 12 if nobody answers."
fullWidth
/>
</Field>
</div>
);
}
Translated
The counter's announcement comes from the locale (French here). Your label and hint are your own text.
Décrivez votre demande en quelques lignes.
import { Field, Textarea, LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import fr from "@vjdesigns/vjdesigns-ui/locales/fr";
export function Translated() {
return (
<LocaleProvider locale="fr" messages={fr}>
<div style={{ width: "100%", maxWidth: "28rem" }}>
<Field label="Message" hint="Décrivez votre demande en quelques lignes.">
<Textarea maxLength={200} showCount minRows={3} defaultValue="Bonjour, je souhaite modifier ma commande." fullWidth />
</Field>
</div>
</LocaleProvider>
);
}
Right to left
The first example again, inside a right-to-left LocaleProvider (Arabic). Layout, spacing and arrow icons mirror, and the components' built-in text is translated. The example's own text stays in English.
Auto resize
import { LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";
// AutoResize is the "Auto resize" example above.
<LocaleProvider locale="ar" messages={ar}>
<AutoResize />
</LocaleProvider>
Usage notes
<label htmlFor="bio">Bio</label>
<Textarea id="bio" autoResize maxRows={8} maxLength={280} showCount />
API reference
Textarea
| Prop | Type | Default |
|---|---|---|
sizeControl size: scales font size and padding. Defaults to the surrounding Field's size, then | "sm""md""lg" | — |
variantVisual style. | "outline""filled" | — |
radiusCorner rounding. Defaults to | "sm""md""lg""none""xs""xl""2xl" | — |
invalidMarks the value invalid: sets | boolean | — |
valueControlled value. | string | — |
defaultValueInitial value when uncontrolled. | string | — |
onValueChangeCalled with the new value on every edit, controlled or not. | (value: string) => void | — |
rowsVisible number of text lines. With | number | — |
autoResizeGrow and shrink with the content between | boolean | — |
minRowsMinimum visible rows when | number | — |
maxRowsMaximum visible rows when | number | — |
resizeDrag-resize handle direction. Defaults to | "none""vertical""both" | — |
showCountShow an "n / max" character counter under the field. Requires | boolean | — |
fullWidthStretch to the full inline size of the container. | boolean | — |
classNameClass name for the wrapper element. | string | — |
textareaClassNameClass name for the | string | — |
refRef to the | Ref<HTMLTextAreaElement> | — |
Also accepts native <textarea> attributes, plus className, style and ref.
See what changed in each version in the Changelog.
Accessibility report
Textarea targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.
axe-core audit (live)
Checking the examples above…
Lighthouse audit
Light mode
Score 10036 passed · 0 failed · 29 not applicable · 10 to check by hand
Dark mode
Score 10036 passed · 0 failed · 29 not applicable · 10 to check by hand
Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.
Built-in behavior
Keyboard
| Key | Action |
|---|---|
| Tab | Moves focus into the text area. |
| Typing | Edits the text, with the browser's usual caret and selection keys. |
Roles and states
| Element | Role | States and properties |
|---|---|---|
<textarea> | textbox (multi-line) | aria-invalid, aria-describedby → hint, error and counter |
| Character counter | none | aria-live="polite" near the limit |
Manual checks
Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.
| Check | What to test | WCAG 2.2 |
|---|---|---|
| Keyboard | Every action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck. | 2.1.1 (A), 2.1.2 (A) |
| Focus | Focus moves in a logical order, is always visible, and isn't hidden behind sticky headers. | 2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA) |
| Screen readers | Names, roles and states are announced correctly, and status changes are announced without moving focus. | 1.3.1 (A), 4.1.2 (A), 4.1.3 (AA) |
| Color | Meaning never depends on color alone; your own colors meet contrast in both modes. | 1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA) |
| Zoom and reflow | At 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed. | 1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA) |
| Pointer targets | Click and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap. | 2.5.8 (AA), 2.5.5 (AAA) |
| Motion | Animations respect the reduced-motion setting. | 2.3.3 (AAA) |