Form
Textarea
A multi-line text box that grows with its content.
Import
import { Textarea } from "@booleanpress/ui/textarea"Usage
Textarea is a styled native textarea. Name it with a Label whose htmlFor is its id.
import { Label } from "@booleanpress/ui/label"
import { Textarea } from "@booleanpress/ui/textarea"
export function Signature() {
return (
<div className="flex flex-col gap-2">
<Label htmlFor="signature">Email signature</Label>
<Textarea id="signature" />
</div>
)
}It takes every attribute of a native textarea. It is uncontrolled with defaultValue, or controlled with value and onChange. It is at least 64 px tall and grows with its text (field-sizing: content); set rows or a max-h-* class to limit it. To put buttons or a counter inside the box, use InputGroupTextarea.
Examples
Basic
A labelled textarea with a placeholder.
Grows with its text
The box is as tall as its content, never shorter than 64 px.
Disabled
A disabled textarea cannot be focused or edited.
Invalid
aria-invalid draws the error border; aria-describedby reads the message with the name.
Accessibility
- Semantics
- A native
textarea, roletextbox, multi-line. - Labels
- Name every textarea: a
LabelwithhtmlFor, oraria-label. A placeholder is not a name. Put hints and errors inaria-describedby. - Focus
- It is in the tab order unless disabled. Tab moves on; it does not insert a tab character. The focus ring shows on keyboard focus.
- Known limits
- Growing with content depends on
field-sizing: content. A browser without it shows the 64 px box with a scrollbar.
- Growing with content depends on
Keyboard
| Key | Behaviour |
|---|
API
Textarea
Renders a textarea and passes it every other prop.
Every part takes className, merged with its defaults by cn(), and ref, which reaches the element it renders.
Data attributes: data-slot="textarea" (Textarea).
Theming
The tokens its classes read. Change their values in your theme, and it follows.
| Token | Used for |
|---|---|
--control | border |
--destructive | border, focus ring |
--input | border, background |
--muted-foreground | text |
--ring | border, focus ring |