Fields
Text Area
A multi-line native text box with the same label and feedback pieces.
When to use it: Use it when people need to write a note, message, or longer answer.
Example
import { Label, TextArea, TextField } from "@comp0/react";
export function Example() {
return (
<TextField as="div" className="flex max-w-xs flex-col gap-1.5">
<Label className="text-base font-medium text-zinc-900 sm:text-sm dark:text-zinc-100">
Feedback
</Label>
<TextArea
className="min-h-28 w-full rounded border border-zinc-950/10 bg-white px-3 py-2.5 text-base text-zinc-950 outline-teal-600 focus-visible:outline-2 sm:py-2 sm:text-sm dark:border-white/10 dark:bg-zinc-900 dark:text-zinc-50 dark:outline-teal-400"
name="feedback"
placeholder="Tell us what you think."
/>
</TextField>
);
}Anatomy
Dashed frames are invisible state providers; shaded shapes own real DOM. Numbered pins match the list below.
A wireframe sketch of the assembled component. Each numbered marker matches a part in the list that follows.
TextField
Optional field provider; it owns no DOM by default. Does not add a DOM element.
Label
Native label for the text area. Owns a DOM element.
TextArea
Native multi-line control that owns typing and submission. Owns a DOM element.
Description / FieldErrorOptional
Optional linked help or error text. Owns a DOM element.
Step by step
- 1
Add the main part
Start a TextField with Label.
- 2
Add the supporting parts
Put TextArea inside it instead of Input.
- 3
Make the behavior clear
Give TextArea a name so the full text submits.
Exampletsx <TextField><Label>Notes</Label><TextArea name="notes" /></TextField>
Keyboard
- ⇥
- Moves to and from the native text area.
Forms and accessibility
TextArea submits its native name and multi-line value.
Accessibility checklist
- Give the multi-line box a visible Label.
- Explain character limits in Description when they matter.
- Use FieldError to state what needs fixing.
API reference
import { Description, FieldError, Label, TextArea, TextField } from "@comp0/react";TextField
Context onlyOptional field provider; it owns no DOM by default.
| Prop | Type | Description |
|---|---|---|
value | string | Controlled field value. |
defaultValue | string | Initial field value. |
onChange | (value: string) => void | Receives the next value. |
disabled / invalid / required | boolean | Field-wide states shared with every part. |
Label
DOM elementNative label for the text area.
| Prop | Type | Description |
|---|---|---|
htmlFor | string | Auto-wired to the field control; set it only to override. |
TextArea
DOM elementNative multi-line control that owns typing and submission.
| Prop | Type | Description |
|---|---|---|
name | string | Submission name for the text. |
rows | number | Visible line count. |
placeholder | string | Hint text; never a replacement for Label. |
disabled / required | boolean | Override the field-wide state for this control. |
Description / FieldError
OptionalDOM elementOptional linked help or error text.
| Prop | Type | Description |
|---|---|---|
forceMount | boolean | FieldError only: keep it rendered while the field is valid. |
Style hooks
Attributes that appear while a state is true. Target them with Tailwind data variants such as data-open:bg-zinc-100, or with any CSS selector.
[data-disabled]on TextArea
- The surrounding field is disabled.
[data-invalid]on TextArea
- The surrounding field is invalid.