Components

Textarea

Multi-line text input with the same box, sizes and states as Input, that can grow with what is typed.

Usage

import { Field, FieldLabel } from 'nyctoui/field'
import { Textarea } from 'nyctoui/textarea'

<Field>
  <FieldLabel>Description</FieldLabel>
  <Textarea />
</Field>

Textarea wraps ui-sdk’s Textarea, a native <textarea>. Inside a Field it is labelled, described and validated just like Input. On its own, give it an aria-label.

It takes every native textarea prop. Use onValueChange to get the text directly, or onChange for the event.

Good for

  • A comment or a reply box in a discussion thread.
  • An issue description in a bug tracker.
  • A message to support in a help widget.
  • A product review on a store page.

Examples

Sizes

The sizes match Input and Button. With rows={1} a textarea is exactly as tall as a button of the same size.

Auto-resize

Set autoResize to grow with the text instead of scrolling, from rows up to maxRows. It uses CSS field-sizing; browsers without it keep a fixed box the user can drag taller.

With a counter

A CharacterCounter in the same field follows the textarea and marks the field invalid past its limit.

Invalid

Native constraints such as required work with FieldError. Here the field checks itself when it loses focus.

Disabled

A disabled textarea dims and can’t be resized.

Best practices

Do
  • Give it a visible label, and a description or placeholder that says what to write.
  • Use autoResize with maxRows, so it grows with the text and then scrolls.
  • Add a character counter when there’s a limit.
  • Keep Return as a new line in a long-form box. For a box that sends, set submitShortcut="mod+enter" so ⌘ Return sends.
Don’t
  • Use a textarea for a one-line value, like a name or an email.
  • Show an error message without also marking the field invalid, so people can see which one is wrong.

API reference

Textarea

Renders a <textarea>, and accepts native textarea props plus onValueChange and submitShortcut.

PropTypeDefault
size
Text size and padding; matches Input sizes.
'sm' | 'md' | 'lg''md'
rows
Visible lines, or the starting height with autoResize.
number3
autoResize
Grows and shrinks with the content instead of scrolling.
booleanfalse
maxRows
With autoResize, the height at which it stops growing and scrolls.
number—
onValueChange
Called with the new text on every change.
(value: string, details) => void—
sx
StyleX styles merged after the built-in ones.
StyleXStyles—