Textarea

A multi-line text control that grows with its content (CSS field-sizing, so a fixed height in browsers without it). Works alone or inside a Field, with the same labelling, validation and data attributes as Input; set rows or a max height with classes.

Installation

npx nuecrea-ui add textarea

Usage

import * as Field from '@/components/ui/field';
import { Textarea } from '@/components/ui/textarea';

export default function TextareaStory() {
  return (
    <main className="grid max-w-sm gap-6">
      <Field.Root validationMode="onBlur">
        <Field.Label>Bio</Field.Label>
        <Textarea
          required
          minLength={10}
          placeholder="A few words about you"
        />
        <Field.Description>Shown on your profile. Grows as you type.</Field.Description>
        <Field.Error match="valueMissing">Write a short bio.</Field.Error>
        <Field.Error match="tooShort">Use at least 10 characters.</Field.Error>
      </Field.Root>
      <Field.Root disabled>
        <Field.Label>Notes</Field.Label>
        <Textarea defaultValue="Managed by your admin." />
      </Field.Root>
    </main>
  );
}

API reference

Textarea

The textarea. Uses native constraint validation; Angular also reads reactive and signal forms errors. Renders <textarea>.

PropTypeDefaultDescription
valuestring—Controlled value.
defaultValuestring—Initial value when uncontrolled.
disabledbooleanfalseDisables the input.
EventPayloadDescription
onValueChangestringFired on every input.
Data attributePresent when
data-disabledthe field is disabled
data-validvalidated and valid
data-invalidvalidated and invalid, or forced invalid
data-dirtythe value differs from the initial value
data-touchedthe control has been blurred
data-filledthe control has a value
data-focusedthe control is focused