Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Textarea

FreeNew

A multi-line field that grows with its content up to a row limit, with an optional character counter.

Installation

pnpm dlx shadcn@latest add @viewport/textarea

First time? Add the @viewport registry to components.json. Setup takes one minute.

Usage

The code behind the preview above.

textarea-demo.tsx
import { Textarea } from "@/components/viewport/textarea";

export default function TextareaDemo() {
  return (
    <div className="flex w-full max-w-sm flex-col gap-3">
      <Textarea aria-label="Note" autosize rows={2} maxRows={8} placeholder="Add a note. The field grows as you type." />
      <Textarea aria-label="Bio" showCount maxLength={160} rows={3} defaultValue="Head of Revenue at Northwind. Previously led partnerships across the Nordics, and still answers every renewal email personally." />
    </div>
  );
}

Props

PropTypeDefault
autosizeboolean

Grow with the text instead of scrolling, up to `maxRows`.

false
maxRowsnumber

The tallest the field gets when `autosize` is set. After that it scrolls.

10
showCountboolean

Show how many characters are used. Needs `maxLength`.

false

Accessibility

  • The counter is visual; a polite message reads the characters left only near the limit.
  • Grows with CSS where the browser supports it, so there is no measuring on each key.
  • Respects prefers-reduced-motion.