Search every page in the navigation.
Displays a form textarea or a component that looks like a textarea.
import { Textarea } from "@/components/ui/textarea"
export default function TextareaDemo() {
return <Textarea placeholder="Type your message here." />
}npx shadcn@latest add @ziiz/textareaimport { Textarea } from "@/components/ui/textarea"<Textarea />A textarea has no fixed height, so size sets only its padding: 12px at sm and default, 16px at lg, matching the input of the same size.
Use the variant prop to change the field's look. default is the outlined field, secondary a gray fill that darkens on hover, and ghost is transparent with no hover, for a field on a toolbar or a surface of its own. They match the outline, secondary and ghost button. A textarea has no shape, since a pill only fits a single line.
import { Textarea } from "@/components/ui/textarea"
function TextareaVariants() {
return (
<div className="flex w-full max-w-xs flex-col gap-3">
<Textarea placeholder="Default" />
<Textarea variant="secondary" placeholder="Secondary" />
<Textarea variant="ghost" placeholder="Ghost" />
</div>
)
}
export default TextareaVariantsUse Field, FieldLabel, and FieldDescription to create a textarea with a label and description.
Enter your message below.
import { Field, FieldDescription, FieldLabel } from "@/components/ui/field"
import { Textarea } from "@/components/ui/textarea"
function TextareaField() {
return (
<Field>
<FieldLabel htmlFor="textarea-message">Message</FieldLabel>
<FieldDescription>Enter your message below.</FieldDescription>
<Textarea id="textarea-message" placeholder="Type your message here." />
</Field>
)
}
export default TextareaFieldUse the disabled prop to disable the textarea. To style the disabled state, add the data-disabled attribute to the Field component.
import { Field, FieldLabel } from "@/components/ui/field"
import { Textarea } from "@/components/ui/textarea"
function TextareaDisabled() {
return (
<Field data-disabled>
<FieldLabel htmlFor="textarea-disabled">Message</FieldLabel>
<Textarea
id="textarea-disabled"
placeholder="Type your message here."
disabled
/>
</Field>
)
}
export default TextareaDisabledUse the aria-invalid prop to mark the textarea as invalid. To style the invalid state, add the data-invalid attribute to the Field component.
Please enter a valid message.
import { Field, FieldDescription, FieldLabel } from "@/components/ui/field"
import { Textarea } from "@/components/ui/textarea"
function TextareaInvalid() {
return (
<Field data-invalid>
<FieldLabel htmlFor="textarea-invalid">Message</FieldLabel>
<Textarea
id="textarea-invalid"
placeholder="Type your message here."
aria-invalid
/>
<FieldDescription>Please enter a valid message.</FieldDescription>
</Field>
)
}
export default TextareaInvalidPair with Button to create a textarea with a submit button.
import { Button } from "@/components/ui/button"
import { Textarea } from "@/components/ui/textarea"
function TextareaButton() {
return (
<div className="grid w-full gap-2">
<Textarea placeholder="Type your message here." />
<Button>Send message</Button>
</div>
)
}
export default TextareaButton