Textarea23
The multi-line sibling of Input: same label, help text, errors and focus lift, for messages, notes and anything longer than a line. It can grow as you type.
<Textarea label="Message" placeholder="Say hello…" />Usage
import { Textarea } from "plonk-ui";
export function Feedback() {
return <Textarea label="Message" name="message" rows={4} />;
}Textarea renders a real <textarea> and passes every native prop to it:
value and onChange, defaultValue, maxLength, rows, ref. className
styles the outer wrapper. description and error work exactly like they do on
Input, and so does
validation.
Growing with the text
autoResize makes the field as tall as its content, up to 20rem, and then it
scrolls. It uses CSS field-sizing; in browsers without it, the field keeps a
fixed height that people can resize by hand.
Grows as you type, then scrolls.
import { Textarea } from "plonk-ui";
export default function AutoResize() {
return (
<Textarea
className="w-full max-w-sm"
label="Release notes"
description="Grows as you type, then scrolls."
autoResize
rows={2}
defaultValue={"Buttons now press harder.\nToasts peel off the corner."}
/>
);
}Character count
Control the value and put the count in description. It sits under the field
and is read along with the label. maxLength stops typing at the limit.
98 characters left
import { useState } from "react";
import { Textarea } from "plonk-ui";
const LIMIT = 140;
export default function Count() {
const [bio, setBio] = useState("Frontend developer. I make buttons squish.");
const left = LIMIT - bio.length;
return (
<Textarea
className="w-full max-w-sm"
label="Bio"
value={bio}
onChange={(event) => setBio(event.target.value)}
maxLength={LIMIT}
description={`${left} characters left`}
/>
);
}Personalities
The field lifts on focus in Sticker, Comic and Retro, and lights a neon ring in Arcade, just like Input. Errors stick on as a tilted tag and shake the field once.
Accessibility
- The label is a real
<label>linked to the field. Without one, passaria-label. descriptionanderrorare linked witharia-describedby;erroralso setsaria-invalid.Tabmoves out of the field;Enteradds a new line and never submits the form.- Screen readers don't repeat the description while you type. For a limit that matters, also check it when the form is submitted.
API
All other <textarea> props are passed through.
| Prop | Type | Default | Description |
|---|---|---|---|
autoResize | boolean | false | Grows with its content (field-sizing: content) up to 20rem, then scrolls. Browsers without support keep a resizable field. |
label | ReactNode | — | Visible label, linked to the control. Without one, pass aria-label or aria-labelledby. |
description | ReactNode | — | Help text under the control, read by screen readers after the label. |
error | ReactNode | — | Error message. When set, the control is marked invalid (aria-invalid) and shakes once. Pass true to mark it without a message. |
rows | number | 3 | Starting height in lines. |
name | string | — | Field name in the submitted form data. |
required | boolean | — | Marks the field required, with an asterisk in the label. |
disabled | boolean | — | Disables the field. The border turns dashed. |