Components
Textarea
A native multi-line input with an invalid state.
Use Textarea for free text over several lines, such as a message or a note. It resizes vertically only, so it can't break your layout.
Installation
pnpm dlx shadcn@latest add https://components.abdulqadirmsingi.com/r/textarea.json
Usage
import { Textarea } from "@/components/ui/textarea";
<Textarea name="message" rows={5} />States
Props
Textarea extends all native <textarea> props and spreads them onto the element, including ref (React 19).
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | "default" | "glass" | "default" | Visual style. |
| halo | boolean | true | The soft grey glow around the focused field. Set false to keep only the border change. |
| invalid | boolean | – | Sets aria-invalid and a danger border. Field sets this for you. |
| className | string | – | Merged with the built-in classes; yours win on conflicts. |
Accessibility
- It renders a native
<textarea>, so Enter inserts a new line and form submission works natively. - It needs a name: use Field or a
Label. - A visible focus ring appears on keyboard focus only.
Tokens used
--background, --foreground, --muted-foreground, --control-border, --danger, --ring, --duration-base, --ease-out, and the glass variables.
Known limitations
- No auto-grow and no character counter yet.
Source
import { cva, type VariantProps } from "class-variance-authority";import type { ComponentProps } from "react";import { cn } from "@/lib/utils";const textareaVariants = cva( "w-full min-w-0 min-h-20 resize-y border px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground transition-[border-color,background-color,box-shadow] duration-[var(--duration-base)] ease-[var(--ease-out)] focus-visible:border-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 aria-[invalid=true]:border-danger aria-[invalid=true]:focus-visible:border-danger aria-[invalid=true]:animate-[zuri-shake_var(--duration-slow)_var(--ease-out)] motion-reduce:animate-none motion-reduce:transition-none", { variants: { // The soft grey glow around a focused field. Off for people who prefer just the border. halo: { true: "focus-visible:ring-4 focus-visible:ring-foreground/10", false: "", }, variant: { default: "rounded-md border-control-border bg-background", glass: "rounded-md zuri-glass", }, }, defaultVariants: { variant: "default", halo: true }, },);export interface TextareaProps extends ComponentProps<"textarea">, VariantProps<typeof textareaVariants> { /** Marks the value as invalid for assistive technology and styles the border. */ invalid?: boolean;}/** A native `<textarea>`. Pair it with a label (see Field) so it has an accessible name. */export function Textarea({ className, variant, halo, invalid, ...props }: TextareaProps) { return ( <textarea aria-invalid={invalid || props["aria-invalid"] || undefined} className={cn(textareaVariants({ variant, halo }), className)} {...props} /> );}export { textareaVariants };