Shadcn Textarea Components

A multi-line text input control. Every textarea variant fits projects standardized on Radix UI or Base UI. Browse our collection of 11 Shadcn Textarea variants.

Please add as many details as you can

0/200

Textarea with tooltip

PJ
Unlock premium components
Get full control of shadcn/ui components, blocks and instances, including future additions.

Explore Shadcn Blocks

Ready-made page sections built with the same components.

View all blocks

Shadcn Textarea Component

The Shadcn Textarea is a multi-line text field for content that does not fit on one line: comments, messages, bios, feedback and descriptions. It is one of the most used form controls, and small details like a clear label, a character counter or an error message make a big difference in how easy a form is to complete.

Autogrowing fields, character counters, Zod validated forms, floating labels and a comment box with the user avatar are among the 11 React textarea examples on this page. The shadcn textarea is a styled native textarea element built with shadcn/ui, React and Tailwind CSS, with no primitive library underneath, so it fits any form setup whether the rest of your UI uses Radix UI or Base UI.

What is the Shadcn Textarea Component?

The shadcn/ui textarea passes every prop straight to the native element, so value, onChange, maxLength, required and disabled work exactly as in plain HTML. It adds theme aware styles for the background, placeholder, focus ring, disabled state and aria-invalid errors, and uses field-sizing: content so it grows with its text in browsers that support it.

Use a textarea when the answer can span several lines or sentences. For short, single-line values such as a name, email or search term, use an Input. To add a label, description and error message with consistent spacing, wrap the textarea in a Field.

Anatomy of the Shadcn Textarea

PartDescription
TextareaThe only exported part: a native textarea with data-slot="textarea". It accepts every textarea attribute plus className, merged with cn(). Labels, helper text and counters are composed around it with other components.

11 Shadcn Textarea Variants

Each textarea variant listed here is previewed live at the top of this page, together with its source code and install command.

  • Basic with label: A textarea linked to a Label through htmlFor and id, with a placeholder.
  • Required, helper text and error: A required field marked with an asterisk, a helper line under the field, and an error state with aria-invalid and a red message.
  • With Zod validation: A React Hook Form field validated with a Zod schema that requires at least 10 characters.
  • Overlapping and floating labels: A label that sits on the top border, and a label that floats up when the field is focused or filled.
  • Autogrowing: Grows with its content up to a maximum height instead of showing a scrollbar right away.
  • Character counter: A controlled textarea with maxLength and a live 0/200 counter below it.
  • With tooltip and avatar: An info icon with a Tooltip inside the label, and a comment box with the user avatar next to it.

How to Install the Shadcn Textarea Component

Set up shadcn/ui in your project if you have not already, then add the Shadcn UI Kit registry to your components.json once:

{
  "registries": {
    "@shadcnuikit": "https://shadcnuikit.com/r/{name}.json"
  }
}

Then install a textarea variant by its name:

npx shadcn@latest add @shadcnuikit/textarea1

The same command works with pnpm dlx, yarn dlx and bunx --bun. Each variant has a copy button for every package manager, and the code is added to your project as plain React and Tailwind CSS that you can edit freely.

How to Use the Shadcn Textarea Component

Import Textarea from components/ui/textarea and connect it to a Label with matching htmlFor and id values. Control it with value and onChange when you need the text in state.

"use client"

import * as React from "react"

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

export function FeedbackField() {
  const [value, setValue] = React.useState("")
  const maxLength = 200

  return (
    <div className="grid w-full max-w-sm gap-2">
      <Label htmlFor="feedback">Your feedback</Label>
      <Textarea
        id="feedback"
        placeholder="Tell us what you think..."
        maxLength={maxLength}
        value={value}
        onChange={(e) => setValue(e.target.value)}
      />
      <p className="text-muted-foreground text-right text-xs">
        {value.length}/{maxLength}
      </p>
    </div>
  )
}

Why Use the Shadcn Textarea Component

  • Native and predictable: It is a real textarea, so browser features, form submission and autofill work without extra code.
  • Works with any form library: Use it uncontrolled, with React state, or with React Hook Form and Zod as in the validation example.
  • Built-in states: Focus, disabled and aria-invalid error styles are already defined with theme tokens.
  • Grows with content: field-sizing: content lets the field expand as users type, without a resize script.
  • Easy to extend: Add counters, floating labels, tooltips or avatars around it with regular JSX and Tailwind classes.

Common Textarea Use Cases

  • Contact and feedback forms: Let users describe a request or a problem in their own words.
  • Comments and replies: Comment boxes with the user avatar in blogs, tasks and code reviews.
  • Chat and AI prompts: A message composer that grows as the prompt gets longer.
  • Profile bios: Short about me fields with a character limit and a live counter.
  • Product and listing descriptions: Longer text fields in admin panels and content editors.
  • Support tickets: Detailed issue descriptions with helper text that asks for specifics.

Customizing the Shadcn Textarea

Pass Tailwind classes through className to change the height, border or background. Set min-h-* and max-h-* to limit how far the field grows, add resize-y to let users resize it manually, or give it border-input bg-background for an outlined look like the floating label variant. Colors come from your theme variables, so a palette from the free Theme Generator applies automatically.

<Textarea
  className="max-h-40 min-h-24 resize-y border-input bg-background"
  placeholder="Write a detailed description..."
/>

Textarea Accessibility and Keyboard Support

Every textarea needs a label. Link a visible Label with htmlFor and id, and use useId() to generate unique ids when the component is reused. A placeholder is not a label, because it disappears as soon as the user starts typing.

For errors, set aria-invalid on the textarea, which also applies the red styles, and connect the message with aria-describedby so screen readers read it with the field. Helper text can be linked the same way.

KeyAction
TabMoves focus into or out of the textarea.
ShiftTabMoves focus to the previous focusable element.
EnterInserts a new line in the text.

Textarea Best Practices

  • Always show a visible label above or on the field, not only a placeholder.
  • Size the field for the expected answer so users can see what they have written.
  • Show a character counter when you set maxLength, so users are not surprised when typing stops.
  • Explain errors in plain words next to the field, and keep the text the user entered.
  • Use helper text for format hints, such as asking for steps to reproduce a bug.
  • For single-line values, use an Input instead.

Components Related to Textarea

Shadcn Textarea FAQ

The shadcn Textarea uses the CSS field-sizing: content property, so it grows with its text in supporting browsers. Limit the growth with a max-h class, for example className="max-h-40", and it scrolls after that height.

Control the textarea with value and onChange, set maxLength, and render value.length next to the limit in a small paragraph below the field, as in the character counter variant.

Define a Zod schema such as z.string().min(10), pass it to React Hook Form with zodResolver, and render the Textarea inside FormControl within a FormField. FormMessage then shows the validation error under the field.

Set aria-invalid on the Textarea. The component switches to a destructive border and ring, and screen readers know the value is invalid. Show the error text below it and link it with aria-describedby.

The component already uses resize-none by default, so users cannot drag the corner. To let them resize it vertically, pass className="resize-y", or use resize for both directions.

Looking for something else? Browse all shadcn/ui components or ready-made UI blocks built with them.