Components

Textarea

An auto-growing React textarea built on shadcn/ui: the drop-in Textarea sizes itself to its content with a soft focus ring and clear invalid state — plus Motion blocks for a textarea that springs to fit with a character-limit counter, and an AI chat input with Enter to send and a loading state.

  • Drop-in shadcn API
  • Server Component friendly
  • Auto-resize
  • Character counter
  • Motion blocks
  • Ship the animated form components today?
Press Enter to send, Shift+Enter for a new line.

Installation

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

Replaces components/ui/textarea.tsx with the same API. The base Textarea is CSS-only — no "use client" needed. It grows with field-sizing: content; browsers without it keep a fixed height.

Usage

feedback.tsx
import { Textarea } from "@/components/ui/textarea"

export function Feedback() {
  return <Textarea aria-label="Feedback" placeholder="What can we improve?" className="max-h-48" />
}

Examples

Default

Start typing: the field grows with its content. Cap it with a max-h-* class and it scrolls from there.

With label & hint

Pair the field with a <label> and link hints with aria-describedby.

Shown on your public profile. Markdown is supported.

Invalid, disabled & fixed

aria-invalid turns the border red, disabled dims it, and field-sizing-fixed with rows gives a classic fixed-height box.

Feedback must be at least 10 characters.

Blocks

Ready-made variations composed from the base component with Motion. Each installs on its own and pulls in its dependencies automatically.

Auto-resize Textarea

Springs to fit its content instead of jumping a line at a time, between minRows and maxRows. With maxLength, a ring fills as you type and turns amber near the limit, then red, with the characters left sliding in. It measures an invisible twin with a ResizeObserver, so it works in every browser.

86 of 180 characters used
$ npx shadcn@latest add https://duskui.com/r/auto-resize-textarea.json
PropTypeDefaultDescription
value / onValueChangestring / (value: string) => void—Controlled text.
defaultValuestring""Uncontrolled initial text.
minRowsnumber2Height when empty, in lines.
maxRowsnumber8Grows up to this many lines, then scrolls.
maxLengthnumber—Character limit; shows the counter ring.
warnAtnumber0.8Fraction of maxLength where the counter turns amber.
enforceLimitbooleantruefalse lets people type past the limit and marks the field invalid instead.
containerClassNamestring—Classes for the wrapper. `className` styles the textarea.

Chat Input

A composer for chat and AI prompts. Enter sends, Shift+Enter adds a line, and IME composition is never interrupted. The send button wakes up with a spring once there is text, and swaps to a spinner without changing size while onSubmit's promise is pending (the DuskUI Button loading prop). If the promise rejects, the text comes back. Put attach or model buttons in actions.

  • Ship the animated form components today?
Press Enter to send, Shift+Enter for a new line.
$ npx shadcn@latest add https://duskui.com/r/chat-input.json
PropTypeDefaultDescription
onSubmit(message: string) => void | Promise—Called with the trimmed text. Return a promise to show loading until it settles.
value / onValueChangestring / (value: string) => void—Controlled text. Uncontrolled inputs clear themselves on send.
defaultValuestring""Uncontrolled initial text.
loadingbooleanfalseShow the spinner and block sending, e.g. while a reply streams.
actionsReactNode—Extra controls on the left of the toolbar.
sendLabelstring"Send message"Accessible name of the send button.
containerClassNamestring—Classes for the outer box. `className` styles the textarea (e.g. max-h-*).

API Reference

Textarea takes every native <textarea> prop, exactly like shadcn/ui.

PropTypeDefaultDescription
classNamestring—Add max-h-* to cap the auto-grow; field-sizing-fixed to turn it off.
rowsnumber—Initial height when field-sizing-fixed is set.
aria-invalidboolean—Red border and ring for validation errors.
disabled / readOnlyboolean—Dimmed, or a muted surface without a focus ring.

Accessibility

  • It is a native <textarea>: name it with a <label htmlFor> or aria-label, and link hints and errors with aria-describedby.
  • Auto-resize Textarea links the counter with aria-describedby and announces only threshold changes ("20 characters left", "Character limit reached") through a polite live region, not every keystroke.
  • Chat Input explains Enter / Shift+Enter in an sr-only hint linked to the field, sets enterKeyHint="send" for mobile keyboards, and keeps the send button focusable while loading (aria-busy + aria-disabled).
  • Under prefers-reduced-motion the height changes instantly and the counter and send button only fade.