Skip to content

Textarea

Multiline text field for entering long text.

Also known as: multiline input, text area, rich text field

View in Storybook

When to use

  • Multiline text entry (descriptions, comments, notes). For single-line text, use Input.
  • For code editing, consider a dedicated code editor.

Import

tsx
import { Textarea } from '@vacano/ui'

Basic Usage

tsx
<Textarea label="Description" placeholder="Enter description..." />

Variants

tsx
<Textarea variant="normal" label="Normal" placeholder="Normal textarea" />
<Textarea variant="error" label="Error" placeholder="Error textarea" />

Rows

The number of visible rows can be configured via the rows prop:

tsx
<Textarea rows={2} label="Small" placeholder="2 rows" />
<Textarea rows={4} label="Default" placeholder="4 rows (default)" />
<Textarea rows={8} label="Large" placeholder="8 rows" />

Full Width

tsx
<Textarea fullWidth label="Full width" placeholder="Expands to container width" />

Disabled

tsx
<Textarea disabled label="Disabled" placeholder="Disabled textarea" />
<Textarea disabled label="Disabled with value" value="Some text" />

Without Label

tsx
<Textarea placeholder="Textarea without label" />

Controlled

tsx
const [value, setValue] = useState('')

<Textarea
  value={value}
  onChange={(e) => setValue(e.target.value)}
  label="Controlled"
  placeholder="Controlled textarea"
/>

With Message

tsx
<Textarea label="Bio" variant="error" message="Bio is required" />
<Textarea label="Notes" message="Optional field" />

With Character Count

tsx
<Textarea label="Description" count={200} placeholder="Max 200 characters" />

Props

PropTypeDefaultDescription
labelstring-Label text above the field
variant'normal' | 'error''normal'Visual variant
rowsnumber4Number of visible rows
fullWidthbooleanfalseTakes full container width
messagestring-Message text below textarea (error, hint)
countnumber-Max character count (shows counter)
classNamestring-CSS class name for the root element
classnamesTextareaClassNames-Custom class names for inner elements
refRef<HTMLTextAreaElement>-Ref to the underlying textarea element
data-test-idstring-Test identifier attribute

All standard HTML textarea attributes are also supported (e.g. value, onChange, placeholder, disabled, name, maxLength, etc.).

ClassNames

KeyDescription
textareaTextarea element
labelLabel element

Released under the MIT License.