Skip to content

Textarea

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.

On this page
Used for
  • Prompt text
  • System instruction
  • Feedback comment
  • Ticket description

Examples

Installation

npx knowns-ui@latest add textarea
For Claude Code, Cursor or Codex: installs it and wires the props to your own data.

Props

autosize
boolean
Defaultfalse
Grow with the text from minRows up to maxRows, then scroll. Re-measures when the width changes.
minRows / maxRows
number
Default3 / 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
Defaultfalse
Show "380 left" (or "20 over") instead of "120 / 500".
resize
"none" | "vertical"
Defaultvertical (none with autosize)
Whether the corner can be dragged.
invalid
boolean
Defaultfalse
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

  1. 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.
  2. 02Counts characters or words with count, using code points for characters so an emoji counts once.
  3. 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.
  4. 04Shows 120 / 500 by default, or 380 left and 20 over with the remaining prop.
  5. 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.
  6. 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

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" }).

Need help?

Stuck on Textarea, or found something off? We read every message.