Components
Textarea
NativeA multi-line text field.
Installation
npx nook-ui@latest add textareaPrompt
Paste this into your AI coding assistant. It adds this exact component, the same way the CLI does, and tells the assistant how to use it.
Short. For assistants that can run commands in your project.
Add the Nook "Textarea" component to this project, exactly as Nook ships it.
A multi-line text field.
Steps
1. Check for `nook.json` in the project root. If it is missing, run `npx nook-ui@latest init` first (React or Next.js with Tailwind CSS v4). It adds the Nook tokens, the theme and `cn()`.
2. Run `npx nook-ui@latest add textarea`. It writes `components/ui/textarea.tsx` together with everything the component needs. Do not write the component from memory.
3. If you cannot run commands, fetch http://localhost:3000/r/textarea.json, write every entry of `files` to the path it names, install the packages in `dependencies`, and repeat for each name in `registryDependencies`.
4. Use it where I ask. Start from this example:
```tsx
import { Label } from "@/components/ui/label";
import { Textarea } from "@/components/ui/textarea";
export default function TextareaDefault() {
return (
<div className="grid w-full max-w-sm gap-2">
<Label htmlFor="bio">Bio</Label>
<Textarea id="bio" placeholder="Tell us a little about yourself" />
</div>
);
}
```
API
- `Textarea`: The textarea element.
- `size` (`"sm" | "md" | "lg"`, default "md"): Least height, padding and text size.
- `...props` (`React.TextareaHTMLAttributes<HTMLTextAreaElement>`): Everything the native element accepts, such as `id`, `aria-*` and event handlers.
- Variant `size`: sm, md, lg (default md)
Rules
- Colors, radii, shadows and motion come from Nook tokens and classes such as `bg-primary`, `text-muted-foreground`, `border-border`, `rounded-lg` and `h-control`. Never hard-code them.
- Do not restyle or simplify the file. Change how it looks through `className`, its props and the theme.
- It must keep working with the keyboard, in light and dark mode, and in the sharp, soft and bold styles.
- Accessibility: Always pair with a Label or `aria-label`.
Done when the component renders like the example in light and dark mode and the project type-checks.Usage
import { Label } from "@/components/ui/label";
import { Textarea } from "@/components/ui/textarea";
export default function TextareaDefault() {
return (
<div className="grid w-full max-w-sm gap-2">
<Label htmlFor="bio">Bio</Label>
<Textarea id="bio" placeholder="Tell us a little about yourself" />
</div>
);
}Examples
Character count
Show how much is left, and say it in words.
95 characters left
Disabled, read-only and invalid
Tell us why, so we can fix it for the next customer.
Sizes
Small, default and large set the least height, padding and text.
Comment box with actions
A real use: write, then act.
Variants
Defined in one place with cva, at the top of the component file.
size
smmd (default)lg
Props
Textarea
The textarea element.
| Prop | Type | Default | Description |
|---|---|---|---|
| size | "sm" | "md" | "lg" | "md" | Least height, padding and text size. |
| ...props | React.TextareaHTMLAttributes<HTMLTextAreaElement> | – | Everything the native element accepts, such as `id`, `aria-*` and event handlers. |
Accessibility
Always pair with a Label or `aria-label`.
Checked against WCAG 2.1 AA with automated axe tests and keyboard tests on every release.