Skip to content

Textarea

Download .md

A textarea takes text that runs over several lines, such as notes or a description, and grows with its content.

  • Use it for notes, descriptions and messages.
  • Use an Input for one line, such as a name or a title.
  • Put it in a Field, with a hint that says the limit, such as “Paling banyak 500 karakter.”
React

Paling banyak 500 karakter.

Vue

Paling banyak 500 karakter.

123
  1. 1Label
  2. 2Field that grows with its text
  3. 3Resize handle

A box on radius-md with an input border, at least min-h-16 tall, that grows with its content (field-sizing-content). Focus shows the ring; an invalid value turns the border destructive.

There is one style.

React Vue Flutter Type Default Use
value / defaultValue v-model / default-value controller / initialValue text none The text.
maxLength maxlength maxLength number none The longest text allowed. Say it in the hint too.
rows rows minHeight number grows with content The starting height.
aria-invalid aria-invalid forceErrorText on ShadTextareaFormField boolean false Marks a refused value.
disabled disabled enabled: false boolean false Blocks typing.
import { useId } from "react"
import { Field, FieldDescription, FieldLabel } from "@/components/ui/field"
import { Textarea } from "@/components/ui/textarea"
export default function TextareaDemo() {
const id = useId()
return (
<Field className="w-full max-w-sm">
<FieldLabel htmlFor={`${id}-notes`}>Catatan untuk tim</FieldLabel>
<Textarea id={`${id}-notes`} maxLength={500} aria-describedby={`${id}-notes-hint`} />
<FieldDescription id={`${id}-notes-hint`}>Paling banyak 500 karakter.</FieldDescription>
</Field>
)
}
Terminal window
npx shadcn@latest add https://design.sosialoka.tech/r/react/textarea.json
  • Give it a visible label in a Field.
  • Tie the hint and any error to it with aria-describedby.
  • It keeps the native textarea keyboard behavior: Enter adds a line, Tab moves on.