Skip to content
Corsair UI
Browse the docs

ComponentsNo. 58 of 109

Textarea

Multi-line text control with the same states as Input.

Installation

pnpm dlx shadcn@latest add @corsair-ui/textarea

No setup needed: the CLI finds @corsair-ui in the shadcn registry directory. The files land in your project as source: edit them like your own code. More in Installation.

Also adds
utils
npm
clsxtailwind-merge

Examples

Default

Invalid

Write at least 20 characters.

Disabled

Accessibility

  • The error style comes from aria-invalid="true".

Compatibility

Tailwind CSS
3.4 and 4, both checked in CI
React
19
Rendering
Works in server components

Source

1 file, installed as source you own
textarea.tsxView on GitHub
import type { ComponentProps } from "react";

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

/** Multi-line text control with the same states as Input. */
function Textarea({ className, ...props }: ComponentProps<"textarea">) {
  return (
    <textarea
      data-slot="textarea"
      className={cn(
        "border-input bg-field flex min-h-16 w-full resize-y rounded-md border px-3 py-2 text-base md:text-sm",
        "transition-[color,border-color,box-shadow] outline-none motion-reduce:transition-none",
        "placeholder:text-muted-foreground",
        "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
        "aria-[invalid=true]:border-destructive aria-[invalid=true]:ring-destructive/20",
        "disabled:cursor-not-allowed disabled:opacity-50",
        className
      )}
      {...props}
    />
  );
}

export { Textarea };