Skip to Content

Textarea

A multi-line text input that grows with its content.

import { Textarea } from "@dapplelight/signet-ui/components/textarea"

export function Demo() {
  return (
    <Textarea placeholder="Add a note for the customer" className="max-w-sm" />
  )
}

Installation

npm i @dapplelight/signet-ui

Usage

import { Textarea } from "@dapplelight/signet-ui/components/textarea"

<Textarea placeholder="Add a note" />

Examples

With label

import { Textarea } from "@dapplelight/signet-ui/components/textarea"
import { Label } from "@dapplelight/signet-ui/components/label"

export function Demo() {
  return (
    <div className="grid w-full max-w-sm gap-2">
      <Label htmlFor="note">Order note</Label>
      <Textarea id="note" placeholder="Leave at the front door" />
    </div>
  )
}

Disabled

import { Textarea } from "@dapplelight/signet-ui/components/textarea"

export function Demo() {
  return (
    <Textarea disabled defaultValue="This ticket is closed." className="max-w-sm" />
  )
}

Invalid

Give at least 20 characters.

import { Textarea } from "@dapplelight/signet-ui/components/textarea"
import { Label } from "@dapplelight/signet-ui/components/label"

export function Demo() {
  return (
    <div className="grid w-full max-w-sm gap-2">
      <Label htmlFor="reason">Refund reason</Label>
      <Textarea id="reason" aria-invalid defaultValue="n/a" />
      <p className="text-sm text-destructive">Give at least 20 characters.</p>
    </div>
  )
}

Character count

0/160

import { useState } from "react"
import { Textarea } from "@dapplelight/signet-ui/components/textarea"
import { Label } from "@dapplelight/signet-ui/components/label"

export function Demo() {
  const [bio, setBio] = useState("")
  return (
    <div className="grid w-full max-w-sm gap-2">
      <Label htmlFor="bio">Bio</Label>
      <Textarea id="bio" value={bio} maxLength={160} onChange={(e) => setBio(e.target.value)} />
      <p className="text-right text-xs text-text-muted">{bio.length}/160</p>
    </div>
  )
}

API Reference

PropTypeDefaultDescription
classNamestring-Merged over the defaults. The height grows with the content (minimum 4rem).

Plus every native <textarea> prop. aria-invalid shows the destructive ring.