Components
- Accordion
- Alert
- Alert Dialog
- Autocomplete
- Avatar
- Badge
- Breadcrumb
- Button
- Card
- Checkbox
- Checkbox Group
- Collapsible
- Combobox
- Dialog
- EmptyNew
- Field
- Fieldset
- Form
- Frame
- Group
- Input
- Input GroupNew
- KbdNew
- Label
- Menu
- Meter
- Number Field
- Pagination
- Popover
- Preview Card
- Progress
- Radio Group
- Scroll Area
- Select
- Separator
- Sheet
- SkeletonNew
- Slider
- SpinnerNew
- Switch
- Table
- Tabs
- Textarea
- Toast
- Toggle
- Toggle Group
- Toolbar
- Tooltip
Resources
Textarea
A native textarea element.
import { Textarea } from "@/components/ui/textarea";
export default function Particle() {
return <Textarea placeholder="Type your message here" />;
}
Installation
pnpm dlx shadcn@latest add @coss/textarea
Usage
import { Textarea } from "@/components/ui/textarea"<Textarea />Examples
Small Size
import { Textarea } from "@/components/ui/textarea";
export default function Particle() {
return <Textarea placeholder="Type your message here" size="sm" />;
}
Large Size
import { Textarea } from "@/components/ui/textarea";
export default function Particle() {
return <Textarea placeholder="Type your message here" size="lg" />;
}
Disabled
import { Textarea } from "@/components/ui/textarea";
export default function Particle() {
return <Textarea disabled placeholder="Can't type here" />;
}
With Label
import { useId } from "react";
import { Label } from "@/components/ui/label";
import { Textarea } from "@/components/ui/textarea";
export default function Particle() {
const id = useId();
return (
<div className="flex flex-col items-start gap-2">
<Label htmlFor={id}>Message</Label>
<Textarea id={id} placeholder="Type your message here" />
</div>
);
}
Form Integration
"use client";
import * as React from "react";
import { Button } from "@/components/ui/button";
import { Field, FieldError, FieldLabel } from "@/components/ui/field";
import { Form } from "@/components/ui/form";
import { Textarea } from "@/components/ui/textarea";
export default function Particle() {
const [loading, setLoading] = React.useState(false);
const onSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
const formData = new FormData(e.currentTarget);
setLoading(true);
await new Promise((r) => setTimeout(r, 800));
setLoading(false);
alert(`Message: ${formData.get("message") || ""}`);
};
return (
<Form className="max-w-64" onSubmit={onSubmit}>
<Field>
<FieldLabel>Message</FieldLabel>
<Textarea
disabled={loading}
name="message"
placeholder="Type your message here"
required
/>
<FieldError>This field is required.</FieldError>
</Field>
<Button disabled={loading} type="submit">
Submit
</Button>
</Form>
);
}
Comparing with shadcn
Compared to shadcn/ui, our Textarea component includes size variants (sm, default, lg) for better density control. For visual consistency, if you're using size="lg" on other form elements like inputs, you should add the same size to textareas as well.