Textarea

Multi-line text input for longer form content

Setup

import { Textarea } from '@fragments-sdk/ui';

Examples

Default

Basic textarea with label

Loading preview...

With Helper Text

Textarea with additional guidance

Loading preview...

Error State

Textarea showing validation error

Loading preview...

Disabled

Non-interactive textarea

Loading preview...

Custom Rows

Textarea with more visible rows

Loading preview...

Sizes

Available size variants

Loading preview...

With Root Props

Pass wrapper attributes/styling via rootProps

Loading preview...

Success State

Textarea showing validated/success styling

Loading preview...

With Character Counter

Textarea with character count and maxLength

Loading preview...

Props

PropTypeDefaultDescription
valuestringNot setControlled value
defaultValuestringNot setDefault value for uncontrolled usage
placeholderstringNot setPlaceholder text
rowsnumber3Number of visible text rows
minRowsnumberNot setMinimum number of rows when auto-resizing
maxRowsnumberNot setMaximum number of rows when auto-resizing
resizeenumnoneverticalhorizontalbothverticalResize behavior
sizeenumsmmdlgmdSize variant
disabledbooleanfalseDisabled state
errorbooleanfalseError state
successbooleanfalseWhether to show success/validated styling
showCharCountbooleanfalseShow character counter when maxLength is set
labelstringNot setLabel text above the textarea
helperTextstringNot setHelper text below the textarea
onChangefunctionNot setCalled when the textarea value changes
onValueChangefunctionNot setValue-first change callback alias: (value: string) => void
onBlurfunctionNot setCalled when textarea loses focus
onFocusfunctionNot setCalled when textarea receives focus
namestringNot setForm field name
maxLengthnumberNot setMaximum character length
requiredbooleanNot setRequired field
aria-labelstringNot setAccessible label for no-visible-label usage
aria-labelledbystringNot setAccessible labelled-by relationship
aria-describedbystringNot setAccessible described-by relationship
rootPropsobjectNot setHTML attributes applied to the wrapper element
classNamestringNot setWrapper class name
styleobjectNot setWrapper styles

Usage Guidelines

When to use

  • Collecting multi-line text (comments, descriptions)
  • Free-form text input that may span multiple lines
  • Message composition fields
  • Code or content editing

When not to use

  • Single-line input (use Input)
  • Rich text editing (use rich text editor)
  • Selecting from predefined options (use Select)

Best practices

  • Set appropriate rows for expected content length
  • Use placeholder to show example format
  • Show character count when maxLength is set
  • Consider auto-resize for better UX
Accessibility
  • Always provide a visible label
  • Use helperText for format hints
  • Error messages should be descriptive