For the complete documentation index, see llms.txt. Markdown variants are available by appending .md to any URL or sending an Accept: text/markdown header. An agent skill is available at /.well-known/agent-skills/site-skill.md.
FrakmentFrakment

Textarea

A multi-line text input with auto-grow support.

textarea.tsx
import type * as React from "react";

import { cn } from "@/lib/utils";

function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
  return (
    <textarea
      className={cn(
        "border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 disabled:bg-input/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 flex field-sizing-content min-h-16 w-full rounded-lg border bg-transparent px-2.5 py-2 text-base transition-colors outline-none focus-visible:ring-3 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-3 md:text-sm",
        className
      )}
      data-slot="textarea"
      {...props}
    />
  );
}

export { Textarea };

Textarea is a styled native <textarea> with field-sizing-content for automatic height, a consistent focus ring, and disabled / invalid states. Every native attribute is forwarded to the underlying <textarea>.

Installation

Usage

textarea.tsx
import { Textarea } from "@/components/ui/textarea";
<DocsBaseSwitcher base="web" component="textarea" className="mb-6" />
textarea.tsx
<Textarea placeholder="Write a message..." />

Anatomy

tsx
<Textarea />
  • Textarea — native <textarea> with data-slot="textarea", field-sizing-content, min-h-16, and Frakment focus / disabled / invalid styling

Examples

Auto-grow

Because of field-sizing-content, the textarea grows to fit its content without JavaScript. Set rows for a minimum height.

textarea-autogrow.tsx
"use client";

import { Textarea } from "@/components/ui/textarea";

export function TextareaAutogrow() {
  return (
    <div className="max-w-sm">
      <Textarea
        defaultValue="field-sizing-content makes this grow automatically without JavaScript."
        placeholder="Type a long message - the textarea grows as you type."
      />
    </div>
  );
}
tsx
<Textarea
  placeholder="Type a long message..."
  defaultValue="field-sizing-content makes this grow automatically."
/>

Disabled

textarea-disabled.tsx
"use client";

import { Textarea } from "@/components/ui/textarea";

export function TextareaDisabled() {
  return (
    <div className="w-full max-w-md">
      <Textarea
        defaultValue="This field is disabled."
        disabled
        placeholder="Disabled textarea"
      />
    </div>
  );
}
tsx
<Textarea
  placeholder="Disabled textarea"
  disabled
  defaultValue="This field is disabled."
/>

Invalid

Set aria-invalid on the textarea to trigger the destructive border and ring.

textarea-invalid.tsx
"use client";

import { Textarea } from "@/components/ui/textarea";

export function TextareaInvalid() {
  return (
    <div className="w-full max-w-md">
      <Textarea
        aria-invalid
        defaultValue="This content is not allowed."
        placeholder="Invalid"
      />
    </div>
  );
}
tsx
<Textarea
  placeholder="Invalid"
  aria-invalid
  defaultValue="This content is not allowed."
/>

With Field

Compose with Field for a label and description around the textarea.

We read every message.

textarea-field.tsx
"use client";

import { Field, FieldDescription, FieldLabel } from "@/components/ui/field";
import { Textarea } from "@/components/ui/textarea";

export function TextareaField() {
  return (
    <div className="w-full max-w-md">
      <Field>
        <FieldLabel htmlFor="feedback">Feedback</FieldLabel>
        <Textarea id="feedback" placeholder="Share your thoughts..." rows={4} />
        <FieldDescription>We read every message.</FieldDescription>
      </Field>
    </div>
  );
}
tsx
<Field>
  <FieldLabel htmlFor="feedback">Feedback</FieldLabel>
  <Textarea id="feedback" placeholder="Share your thoughts..." rows={4} />
  <FieldDescription>We read every message.</FieldDescription>
</Field>

In Context

Comment box

textarea-comment.tsx
"use client";

import { Label } from "@/components/ui/label";
import { Textarea } from "@/components/ui/textarea";

export function TextareaComment() {
  return (
    <div className="mx-auto flex w-full max-w-sm flex-col gap-2">
      <Label htmlFor="comment">Comment</Label>
      <Textarea id="comment" placeholder="Write a reply…" rows={3} />
    </div>
  );
}

Bio field with limit

Max 160 characters.

textarea-bio.tsx
"use client";

import { Label } from "@/components/ui/label";
import { Textarea } from "@/components/ui/textarea";

export function TextareaBio() {
  return (
    <div className="mx-auto flex w-full max-w-sm flex-col gap-2">
      <Label htmlFor="bio">Bio</Label>
      <Textarea id="bio" placeholder="A few words about you…" rows={4} />
      <p className="text-muted-foreground text-xs">Max 160 characters.</p>
    </div>
  );
}

API Reference

Textarea

Extends React.ComponentProps<"textarea">.

PropTypeDefaultDescription
rowsnumber2Initial visible rows.
placeholderstring—Shown when empty.
valuestring—Controlled value.
defaultValuestring—Uncontrolled initial value.
onChangeReact.ChangeEventHandler<HTMLTextAreaElement>—Fires on every keystroke.
disabledbooleanfalseRemoves from the tab order.
aria-invalidboolean—Marks invalid; pair with aria-describedby.

Accessibility

  • Textarea renders a native <textarea>. Always pair with a Label or FieldLabel.
  • rows sets the initial height; the textarea grows with content when field-sizing-content is applied.
  • Set aria-invalid and aria-describedby on error, same as Input.
  • Provide a character count via aria-describedby when a hard limit exists.

Best Practices

  • Set a sensible rows default. Two to four rows is enough for most forms.
  • Auto-grow with care. field-sizing-content is convenient but can push the submit button off-screen in long replies.
  • Add a character count when a limit exists.
  • Keep the submit shortcut consistent. Cmd+Enter or Ctrl+Enter sends; Enter inserts a newline.
  • Do not use Textarea for a single line. Use Input instead.