For AI agents: the complete documentation index is available at https://ifhover.github.io/leaf-ui/en/llms.txt, the full documentation bundle is available at https://ifhover.github.io/leaf-ui/en/llms-full.txt, and this page is available as Markdown at https://ifhover.github.io/leaf-ui/en/components/textarea.md.

Textarea

Enter multiple lines of text, such as a message, description or note.

Basic usage

Edit multiline text in the textarea and provide an associated field label.

basic.tsx
import { Form, FormField, Textarea } from '@ifhover/leaf-ui';

export function TextareaBasic() {
  return (
    <Form layout="vertical">
      <FormField label="Project description">
        <Textarea name="description" placeholder="Describe your new idea" />
      </FormField>
    </Form>
  );
}

Examples

States

Use readOnly, disabled or a FormField error to communicate field state.

states.tsx
import { Form, FormField, Textarea } from '@ifhover/leaf-ui';

export function TextareaStates() {
  return (
    <Form layout="vertical">
      <FormField label="Read only">
        <Textarea defaultValue="The public project description." readOnly />
      </FormField>
      <FormField label="Disabled">
        <Textarea placeholder="Currently unavailable" disabled />
      </FormField>
      <FormField label="Error" error="Add a description.">
        <Textarea placeholder="Add a description" />
      </FormField>
    </Form>
  );
}

Automatic height

autoSize adjusts height to the content. Bound the row count with minRows and maxRows; additional content scrolls inside the textarea.

auto-size.tsx
import { Form, FormField, Textarea } from '@ifhover/leaf-ui';

export function TextareaAutoHeight() {
  return (
    <Form layout="vertical">
      <FormField label="Project description">
        <Textarea autoSize={{ minRows: 2, maxRows: 6 }} placeholder="Type more content" />
      </FormField>
    </Form>
  );
}

Character count

Set showCount to display the count and maxLength to limit input length.

21 / 120
count.tsx
import { Form, FormField, Textarea } from '@ifhover/leaf-ui';

export function TextareaCount() {
  return (
    <Form layout="vertical">
      <FormField label="Notes">
        <Textarea showCount maxLength={120} defaultValue="Start your plan here." />
      </FormField>
    </Form>
  );
}

Controlled input

Manage content with value and onChange. The example derives its length hint from the current value.

0 / 120
controlled.tsx
import { Form, FormField, Textarea } from '@ifhover/leaf-ui';
import { useState } from 'react';

export function TextareaControlled() {
  const [value, setValue] = useState('');
  return (
    <Form layout="vertical">
      <FormField label="Message" help={`${value.length} / 120`}>
        <Textarea
          value={value}
          maxLength={120}
          resize="none"
          placeholder="Up to 120 characters"
          onChange={(event) => setValue(event.target.value)}
        />
      </FormField>
    </Form>
  );
}

Forms

Provide a name with FormField or aria-label. Set name for native form submission. Uncontrolled values support form reset; reset controlled values in application state. See Form for form integration.

API

Textarea API

Configure multiline text, length limits and input state.

PropertyTypeDefaultDescription
size'sm' | 'md' | 'lg''md'Control size
status'error' | 'warning'—Validation appearance
rowsnumber3Initial visible rows
resize'none' | 'vertical' | 'both''vertical'Allowed manual resizing direction
value / defaultValuestring | number | readonly string[]—Controlled value / initial uncontrolled value
onChangeChangeEventHandler<HTMLTextAreaElement>—Read event.target.value
disabled / readOnlybooleanfalseDisabled / read-only
refRef<HTMLTextAreaElement>—DOM reference
autoSizeboolean | TextareaAutoSizefalseResize to content with optional row limits
showCountboolean | ((value: string, maxLength?: number) => ReactNode)falseDisplay count or a custom renderer

TextareaAutoSize API

Limit the minimum and maximum rows used by automatic height adjustment.

PropertyTypeDefaultDescription
minRowsnumber—Minimum rows
maxRowsnumber—Maximum rows