Forms

Textarea.

A multi-line text field that grows with its content, with invalid and disabled states.

Shown on the site's guestbook page.

Installation#

With the CLI

$npx lanterncn add textarea

This also installs the Lantern theme and any Lantern UI components it depends on. The shadcn CLI works directly too: npx shadcn@latest add httptim/lantern-ui/textarea. See Installation if your project is not set up yet.

Manually

  1. Copy the source 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-20 w-full min-w-0 rounded-md border border-input bg-background/40 px-3 py-2 text-sm leading-relaxed text-foreground transition-[border-color,box-shadow] outline-none placeholder:text-muted-foreground/70 selection:bg-primary selection:text-primary-foreground",
            "hover:border-muted-foreground/60 focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-ring/25",
            "aria-invalid:border-destructive aria-invalid:ring-destructive/20 disabled:cursor-not-allowed disabled:opacity-50",
            className,
          )}
          {...props}
        />
      );
    }
    
    export { Textarea };
  2. Update the import paths to match your project

    The source imports cn from @/lib/utils.

Usage#

import { Textarea } from "@/components/ui/textarea";
<Textarea placeholder="Sign the guestbook" />

Examples#

Invalid and disabled

Line 1: missing closing parenthesis.