shadcn.io is not affiliated with official shadcn/ui
Installation
bunx --bun shadcn@latest add https://kit.dev/r/aria/textarea.jsonnpx shadcn@latest add https://kit.dev/r/aria/textarea.jsonpnpm dlx shadcn@latest add https://kit.dev/r/aria/textarea.jsonyarn shadcn@latest add https://kit.dev/r/aria/textarea.jsonInstall the following dependencies:
bun add react-aria-componentsnpm install react-aria-componentspnpm add react-aria-componentsyarn add react-aria-componentsCopy and paste the following code into your project.
"use client";
import type React from "react";
import {
composeRenderProps,
TextArea as TextareaPrimitive,
} from "react-aria-components";
import { cn } from "@/lib/utils";
export const Textarea = (
props: React.ComponentProps<typeof TextareaPrimitive>
) => {
const { className, ...rest } = props;
return (
<TextareaPrimitive
className={composeRenderProps(className, (renderClassName) =>
cn(Update the import paths to match your project setup.
Usage
import { Textarea } from "@/components/ui/textarea";const TextareaDemo = () => (
<Textarea className="max-w-xs" placeholder="Type your message here." />
);Demos
Field
Use Field, FieldLabel, and FieldDescription to create a textarea with a label and description.
Disabled
Use the disabled prop to disable the textarea. To style the disabled state, add the data-disabled attribute to the Field component.
Invalid
Use the aria-invalid prop to mark the textarea as invalid. To style the invalid state, add the data-invalid attribute to the Field component.
Button
Pair with Button to create a textarea with a submit button.
Rtl
Right-to-left textarea. See the RTL configuration guide for document direction.
API Reference
Textarea
PropType
className?stringAttributeType