A multi-line field in the look of Input. It can grow with its text up to a row limit, and count characters or words against a soft or hard limit, read out only when you near it.
Used for
- Prompt text
- System instruction
- Feedback comment
- Ticket description
Examples
Installation
npx knowns-ui@latest add textareaFor Claude Code, Cursor or Codex: installs it and wires the props to your own data.
Paste this into your coding agent (Claude Code, Cursor, Codex). It checks your project, sets up the registry, runs the install and verifies it.
Install prompt
Install Textarea from Knowns UI into this project. Work step by step, show me each change, and ask before you edit files outside this project.
Context: Knowns UI (https://ui.knowns.dev) is a shadcn registry. Items land in the project as source files. Docs: https://ui.knowns.dev/docs/textarea
1. Check the project first. Stop and tell me if any of these is missing:
- React 19 and Tailwind CSS v4.
- A components.json at the project root. If there is none, ask me before running `npx knowns-ui@latest init --no-key` (it runs shadcn init when needed, then adds the registries).
2. Run:
```bash
npx knowns-ui@latest add textarea
```
It writes these files:
- lib/knowns/run.ts
- lib/knowns/json.tsx
- lib/knowns/status.ts
- lib/knowns/tone.ts
- lib/knowns/types.ts
- lib/knowns/use-abortable.ts
- lib/knowns/utils.ts
- components/ui/knowns/field-class.ts
- components/ui/knowns/textarea.tsx
- components/ui/knowns/chat-composer/use-autosize.ts
and installs these npm packages: clsx@^2.1.1, tailwind-merge@^3.7.0.
3. While it runs:
- It also adds a few @keyframes (all named kn-*) to the global CSS file (globals.css or the file components.json points at). Let it: they only add animations.
- If it asks to overwrite files under lib/knowns/: these are shared by every Knowns UI item. List them, say whether I changed them (check git), and ask me before you answer.
- If it asks to overwrite any other file, show me the diff and ask me.
4. Verify:
- Every file in the list above exists.
- The project type-checks (for example `npx tsc --noEmit`) and the dev build has no new errors.
5. Use it: follow the examples and props on https://ui.knowns.dev/docs/textarea, and ask me if anything about my data is unclear.
If the Knowns UI MCP server is connected (https://ui.knowns.dev/docs/ai-and-mcp), use get_component({ name: "textarea" }) or search_docs for details.
Finish with a short summary: the files you added or changed, the packages you installed, and anything I still need to do.Props
- autosize
boolean- Default
false - Grow with the text from minRows up to maxRows, then scroll. Re-measures when the width changes.
- minRows / maxRows
number- Default
3 / 10 - Rows when empty, and the most rows before it scrolls (with autosize).
- count
"characters"|"words"- Show a counter under the field. Implied by limit and maxLength.
- limit
number- A soft limit. Typing is allowed; passing it turns the counter red and sets aria-invalid.
- maxLength
number- A hard limit in characters, enforced by the browser.
- remaining
boolean- Default
false - Show "380 left" (or "20 over") instead of "120 / 500".
- resize
"none"|"vertical"- Default
vertical (none with autosize) - Whether the corner can be dragged.
- invalid
boolean- Default
false - Red ring. Set automatically when over a soft limit.
- a11y
status- The counter is part of the field's description. A polite status speaks only when you near (80%), reach or pass the limit, not on every key.
| Prop | Type | Default | Description |
|---|---|---|---|
| autosize | boolean | false | Grow with the text from minRows up to maxRows, then scroll. Re-measures when the width changes. |
| minRows / maxRows | number | 3 / 10 | Rows when empty, and the most rows before it scrolls (with autosize). |
| count | "characters" | "words" | - | Show a counter under the field. Implied by limit and maxLength. |
| limit | number | - | A soft limit. Typing is allowed; passing it turns the counter red and sets aria-invalid. |
| maxLength | number | - | A hard limit in characters, enforced by the browser. |
| remaining | boolean | false | Show "380 left" (or "20 over") instead of "120 / 500". |
| resize | "none" | "vertical" | vertical (none with autosize) | Whether the corner can be dragged. |
| invalid | boolean | false | Red ring. Set automatically when over a soft limit. |
| a11y | status | - | The counter is part of the field's description. A polite status speaks only when you near (80%), reach or pass the limit, not on every key. |
What it handles
- 01Grows with its text from minRows up to maxRows, then scrolls, by measuring scrollHeight again on every change and when the field's width changes.
- 02Counts characters or words with count, using code points for characters so an emoji counts once.
- 03Treats limit as a soft limit that turns the counter red and sets aria-invalid when passed, and maxLength as a hard limit that stops input.
- 04Shows 120 / 500 by default, or 380 left and 20 over with the remaining prop.
- 05Describes the counter to the field and speaks only when the state changes to near (from 80%), at or over the limit, not on every key.
- 06Sets resize to vertical for a fixed box and none for an auto-growing one unless you override it with the resize prop.
States
- First render
- Nothing. Autosize measures before paint and sets the height
- none
- Typing with autosize
- The height follows the text line by line, up to maxRows
- none, at once
- Focus
- The hairline becomes a ring with a soft halo
- 180ms, ease out
- Counter at the limit
- The counter text turns red
- 180ms, ease out
- Counter near the limit
- A status message is announced; the visible text stays muted
- none
- Disabled
- The field dims and the cursor changes
- none, at once
| State | What moves | Timing |
|---|---|---|
| First render | Nothing. Autosize measures before paint and sets the height | none |
| Typing with autosize | The height follows the text line by line, up to maxRows | none, at once |
| Focus | The hairline becomes a ring with a soft halo | 180ms, ease out |
| Counter at the limit | The counter text turns red | 180ms, ease out |
| Counter near the limit | A status message is announced; the visible text stays muted | none |
| Disabled | The field dims and the cursor changes | none, at once |
Works with
When to use
When to use
- A message, a note or a prompt of more than one line, optionally with a character or word limit.
- A field that should grow with what people write instead of scrolling a small box.
When not to use
- A single line of text: use Input.
- A chat box with send, attachments and shortcuts: use Chat Composer.
Using with AI
Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:
- Add the Knowns UI Textarea to my app and wire it to my own data.
- I need a message, a note or a prompt of more than one line, optionally with a character or word limit. Set that up with the Knowns UI Textarea.
- Which Textarea props do I need for a minimal setup? Show me a short example.
With the server connected, your assistant calls get_component({ name: "textarea" }) and search_docs({ query: "textarea" }).