All components
Textarea
A hand-drawn textarea that grows with its content.
Default
With value
Invalid
Disabled
Installation
Add Textarea with the shadcn CLI.
npx shadcn@latest add https://sketchcn.chuwii.com/r/textarea.json
Examples
Counted feedback fields and full comment forms.
With a character counter
0/120
import { Textarea } from "@/components/ui/textarea";

const FEEDBACK_LIMIT = 120;

export function FeedbackField() {
  const [feedback, setFeedback] = useState("");

  return (
    <div className="flex w-full flex-col gap-1.5">
      <Textarea
        value={feedback}
        maxLength={FEEDBACK_LIMIT}
        onChange={(event) => setFeedback(event.target.value)}
        placeholder="What did you think?"
      />
      <span className="self-end text-muted-foreground text-xs">
        {feedback.length}/{FEEDBACK_LIMIT}
      </span>
    </div>
  );
}
Comment form
import { Button } from "@/components/ui/button";
import { Textarea } from "@/components/ui/textarea";

export function CommentForm() {
  const id = useId();

  return (
    <form className="flex w-full flex-col gap-2">
      <label htmlFor={id} className="text-sm">
        Leave a note
      </label>
      <Textarea id={id} rows={4} placeholder="Sketch a longer thought" />
      <div className="flex justify-end gap-2">
        <Button variant="ghost" type="reset">
          Clear
        </Button>
        <Button type="submit">Post</Button>
      </div>
    </form>
  );
}