Overview
Get Started
Components
- Accordion
- Alert Dialog
- Alert
- Autocomplete
- Avatar
- Badge
- Button Group
- Button
- Calendar
- Checkbox Group
- Checkbox
- Collapsible
- Combobox
- Command
- Dialog
- Field
- Form
- Input Group
- Input
- Kbd
- Label
- Menu
- Meter
- Navigation Menu
- Number Field
- Number InputNew
- OTP Field
- Pagination
- Popover
- Radio Group
- Scroll Area
- Select
- Sheet
- Sidebar
- Slider
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Tooltip
Textarea
Displays a form textarea or a component that looks like a textarea.
import { Textarea } from "@/components/ui/textarea";
export function TextareaDemo() {
return <Textarea placeholder="Type your message here." className="max-w-sm" />;
}Installation
pnpm dlx @zbmui/cli@latest add textarea
Usage
import { Textarea } from "@/components/ui/textarea";<Textarea />Examples
Sizes
import { Textarea } from "@/components/ui/textarea";
export function TextareaDemo() {
return (
<div className="flex w-full max-w-sm flex-col gap-3">
<Textarea size="xs" placeholder="Type your message here." />
<Textarea size="sm" placeholder="Type your message here." />
<Textarea size="default" placeholder="Type your message here." />
<Textarea size="lg" placeholder="Type your message here." />
<Textarea size="xl" placeholder="Type your message here." />
</div>
);
}Disabled
import { Textarea } from "@/components/ui/textarea";
export function TextareaDemo() {
return <Textarea disabled placeholder="Type your message here." className="max-w-sm" />;
}Invalid
import { Textarea } from "@/components/ui/textarea";
export function TextareaDemo() {
return <Textarea aria-invalid placeholder="Type your message here." className="max-w-sm" />;
}Resize
By default, the textarea is resizable vertically. You can customize the resize behavior using CSS resize property.
import { Textarea } from "@/components/ui/textarea";
export function TextareaDemo() {
return (
<div className="flex w-full max-w-sm flex-col gap-5 *:flex *:flex-col *:gap-2">
<div>
<label htmlFor="resize-horizontal" className="inline-block font-medium text-sm">
Resize horizontal:
</label>
<Textarea
id="resize-horizontal"
placeholder="Type your message here."
className="max-w-sm resize-x"
/>
</div>
<div>
<label htmlFor="resize-both" className="inline-block font-medium text-sm">
Resize both:
</label>
<Textarea
id="resize-both"
placeholder="Type your message here."
className="max-w-sm resize"
/>
</div>
<div>
<label htmlFor="resize-none" className="inline-block font-medium text-sm">
Resize none:
</label>
<Textarea
id="resize-none"
placeholder="Type your message here."
className="max-w-sm resize-none"
/>
</div>
</div>
);
}Field
Render FieldControl as Textarea to integrate with Field component. This allows you to use FieldLabel, FieldDescription, and FieldError components seamlessly with the textarea.
Make sure to be respectful and follow our community guidelines.
import { Field, FieldControl, FieldDescription, FieldLabel } from "@/components/ui/field";
import { Textarea } from "@/components/ui/textarea";
export function TextareaDemo() {
return (
<Field className="max-w-sm">
<FieldLabel>Enter your message</FieldLabel>
<FieldControl render={<Textarea placeholder="Type your message here." />} />
<FieldDescription>
Make sure to be respectful and follow our community guidelines.
</FieldDescription>
</Field>
);
}API Reference
Textarea props
Component type props
Prop
Type
Default
Expand prop details
The size of the textarea.
Type
"xs" | "sm" | "default" | "lg" | "xl"Default
"default"