Textarea
Displays a form textarea or a component that looks like a textarea.
Loading…
"use client"
import { Textarea } from "@/components/ui/textarea"
export default function TextareaDemo() {
return <Textarea aria-label="Message" placeholder="Type your message here." />
}Installation
pnpm dlx shadcn@latest add @kickresume/textareaUsage
import { Textarea } from "@/components/ui/textarea"<Textarea aria-label="Message" placeholder="Type your message here." />Examples
Field
Use Field, FieldLabel, and FieldDescription to create a textarea with a label and description.
Loading…
"use client"
import { Field, FieldDescription, FieldLabel } from "@/components/ui/field"
import { Textarea } from "@/components/ui/textarea"
export default function TextareaField() {
return (
<Field className="max-w-xs">
<FieldLabel htmlFor="textarea-message">Message</FieldLabel>
<FieldDescription>Enter your message below.</FieldDescription>
<Textarea id="textarea-message" placeholder="Type your message here." />
</Field>
)
}Disabled
Use the disabled prop to disable the textarea. To style the disabled state, add the data-disabled attribute to the Field component.
Loading…
"use client"
import { Field, FieldLabel } from "@/components/ui/field"
import { Textarea } from "@/components/ui/textarea"
export default function TextareaDisabled() {
return (
<Field className="max-w-xs" data-disabled>
<FieldLabel htmlFor="textarea-disabled">Message</FieldLabel>
<Textarea
id="textarea-disabled"
placeholder="Type your message here."
disabled
/>
</Field>
)
}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.
Loading…
"use client"
import { Field, FieldDescription, FieldLabel } from "@/components/ui/field"
import { Textarea } from "@/components/ui/textarea"
export default function TextareaInvalid() {
return (
<Field className="max-w-xs" data-invalid>
<FieldLabel htmlFor="textarea-invalid">Message</FieldLabel>
<Textarea
id="textarea-invalid"
aria-describedby="textarea-invalid-description"
placeholder="Type your message here."
aria-invalid
/>
<FieldDescription id="textarea-invalid-description">
Please enter a valid message.
</FieldDescription>
</Field>
)
}Button
Pair with Button to create a textarea with a submit button.
Loading…
"use client"
import { Button } from "@/components/ui/button"
import { Field, FieldLabel } from "@/components/ui/field"
import { Textarea } from "@/components/ui/textarea"
export default function TextareaButton() {
return (
<Field className="w-full max-w-xs">
<FieldLabel htmlFor="textarea-button-message" className="sr-only">
Message
</FieldLabel>
<Textarea
id="textarea-button-message"
placeholder="Type your message here."
/>
<Button>Send message</Button>
</Field>
)
}