cortexcn

Textarea

Displays a multi-line text input field.

Loading…
import { Label } from "@/components/ui/label";import { Textarea } from "@/components/ui/textarea";export default function TextareaDemo() {  return (    <div className="grid w-full max-w-sm gap-2">      <Label htmlFor="message">Your message</Label>      <Textarea id="message" placeholder="Type your message here." />    </div>  );}

Installation

npx shadcn@latest add @cortexcn/textarea
Copy and paste the following code into your project.
components/ui/textarea.tsx
import * as React from "react";import { cn } from "@/lib/utils";function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {  return (    <textarea      data-slot="textarea"      className={cn(        "flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:ring-destructive/40",        className,      )}      {...props}    />  );}export { Textarea };

Usage

import { Textarea } from "@/components/ui/textarea";
<Textarea placeholder="Type your message here." />

Examples

With Button

Loading…
import { Button } from "@/components/ui/button";import { Textarea } from "@/components/ui/textarea";export default function TextareaWithButton() {  return (    <div className="grid w-full max-w-sm gap-2">      <Textarea placeholder="Type your message here." />      <Button>Send message</Button>    </div>  );}

Disabled

Loading…
import { Textarea } from "@/components/ui/textarea";export default function TextareaDisabled() {  return (    <Textarea disabled placeholder="Disabled" className="w-full max-w-sm" />  );}

On this page