Textarea

Free

A text area that opens at three lines and grows to eight as you write, with a counter that turns orange near its limit; its reason kind is where saying no to an agent comes with a why.

npx shadcn@latest add https://pixilui.com/r/textarea.json

Preview

Grows as you write, with a counter that warns near the limit.
Kind

When to use

Use it when

  • Instructions, notes and descriptions.
  • The reason for a denial (kind="reason"), so the agent can tell the customer.

Use something else when

  • One line: use Input.
  • A chat composer: use the composer.

Installation

Terminal
npx shadcn@latest add https://pixilui.com/r/textarea.json

Adds textarea.tsx with field.tsx, and installs clsx and tailwind-merge. The URL works in any app with a components.json, with no registry to add first.

Usage

example.tsx
import { Textarea } from "@/components/pixilui/textarea";

<Textarea />

Fills its container's width; the label row and the message wrap.

API reference

PropTypeDefault
labelReactNode–The label above the field.
hintReactNode–Right of the label: "Optional". A counter takes its place when counter is on.
counterboolean–Show the count of what is typed against maxLength in the hint's place.
formatCount(value: number, max?: number) => string–How the counter reads; "118 / 600" by default.
descriptionReactNode–Help under the field.
errorReactNode–An error from outside, in plain words.
validateFieldValidate–The field's rule, run on blur: return what is wrong, nothing, or a promise.

Also takes every native <textarea> attribute except size, and a ref.

Keyboard

TabMoves into the field.
EnterStarts a new line.

Accessibility

  • The label names the input (aria-labelledby) and the help or error describes it (aria-describedby), so a hint or a counter is never read as its name.
  • An error sets aria-invalid and says what is wrong in words; the color is never the only sign.
  • The counter is in the label row and is not read as the name.

Motion

  • It grows with its text up to eight lines, then scrolls; nothing animates on keys.
  • An error shakes the well once. Reduced motion: no shake.
InputA field that checks what you typed and says what's wrong in words.
FieldOne field frame: a rim you can see, and words that say what's wrong.
AI fieldA still gradient rim marks the field that asks the agent.

PixilUI Pro opens soon. The first 20 licenses are $99.