shadcn.io is not affiliated with official shadcn/ui
Shadcn Textarea for React and Tailwind
Form textarea or textarea-styled component.
Installation
bunx --bun shadcn@latest add https://kit.dev/r/textarea.jsonpnpm dlx shadcn@latest add https://kit.dev/r/textarea.jsonnpx shadcn@latest add https://kit.dev/r/textarea.jsonyarn shadcn@latest add https://kit.dev/r/textarea.jsonInstall the following dependencies:
bun add @ark-ui/reactpnpm add @ark-ui/reactnpm install @ark-ui/reactyarn add @ark-ui/reactCopy and paste the following code into your project.
"use client";
import { Field as ArkField } from "@ark-ui/react/field";
import type React from "react";
import { cn } from "@/lib/utils";
export const Textarea = (
props: React.ComponentProps<typeof ArkField.Textarea>
) => {
const { className, ...rest } = props;
return (
<ArkField.Textarea
className={cn(
"field-sizing-content min-h-16 w-full",
"flex",
"px-3 py-2",
"bg-transparent dark:bg-input/30",
"text-base md:text-sm",
"rounded-lg border border-input shadow-xs/5",
"placeholder:text-muted-foreground/64",
"transition-[color,box-shadow]",
"outline-none focus-visible:border-primary focus-visible:ring-[3px] focus-visible:ring-ring/32",
"aria-invalid:border-destructive aria-invalid:text-destructive aria-invalid:ring-[3px] aria-invalid:ring-destructive/24",
"data-invalid:border-destructive data-invalid:text-destructive data-invalid:ring-[3px] data-invalid:ring-destructive/24",
"dark:aria-invalid:border-destructive-foreground dark:aria-invalid:text-destructive-foreground dark:aria-invalid:ring-destructive-foreground/40",
"dark:data-invalid:border-destructive-foreground dark:data-invalid:text-destructive-foreground dark:data-invalid:ring-destructive-foreground/40",
"disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-64",
"motion-reduce:transition-none!",
className
)}
data-slot="textarea"
{...rest}
/>
);
};Update the import paths to match your project setup.
Usage
import { Textarea } from "@/components/ui/textarea";<Textarea />Controlled
Control the value with value and onChange.
States
Disabled
Disable the textarea with the disabled prop. Use Field with disabled to disable the whole field (label + textarea).
Invalid
Use the invalid prop on Field or Textarea to show invalid state.
Examples
Autoresize
Use autoresize to make the textarea grow with content.
With Field
Wrap the textarea in a Field and add FieldLabel and FieldDescription.
With Input Group
Use FieldGroup to group multiple Field blocks. Combine textarea with other inputs and action buttons.
Form Integration
API Reference
Textarea
Multi-line text input. Accepts all native textarea attributes.
| Prop | Type | Default |
|---|---|---|
autoresize | boolean | true |
className | string | - |
For a complete list of props, see the Ark UI documentation.