@akhatmirzo/ui

Textarea

A multi-line text field that can grow with its content and count characters.

Import

import { Textarea } from '@akhatmirzo/ui';

When to use

  • For free-form, multi-line text — comments, addresses, reviews, messages. For single-line values, use Input.
  • Always inside a Field — the label, hint and error get wired up for you.
  • Use autoResize for chat and comment boxes: the field grows as you type and scrolls inside once it reaches maxRows.
  • If there's a limit, pair maxLength with showCount so people can see how much room is left.

Auto-resize

With autoResize, the height follows the content between minRows and maxRows. Without maxRows, it grows without limit. Manual resizing is turned off in this mode.

Character count

showCount shows the number of characters below the field; with maxLength it reads "64 / 120". The count turns red when you hit the limit.

66 / 120

States and sizes

The same states as Input: invalid, disabled and readOnly. Sizes (sm, md, lg) change the padding and font size; minRows controls the height.

With Field

Kuryer uchun qo'shimcha ma'lumot

0 / 300

Props

Textarea accepts every other <textarea> attribute (name, placeholder, maxLength, onChange ...), and ref points to the inner <textarea>. Use minRows instead of rows. className goes to the outer container; use textareaClassName for the inner element.

PropTypeDefaultDescription
size'sm' | 'md' | 'lg''md'Padding and font size
invalidboolean—Error state (automatic inside a Field with an error)
autoResizebooleanfalseHeight grows with the content (minRows .. maxRows)
minRowsnumber3Initial (and minimum) number of rows
maxRowsnumber—Maximum rows with autoResize; scrolls inside after that
showCountbooleanfalseCharacter count; "120 / 500" with maxLength
textareaClassNamestring—Class for the inner <textarea>
readOnlybooleanfalseRead-only

Data attributes

Set on the outer container (data-slot="textarea"): data-size, data-invalid, data-disabled and data-readonly. The counter element has data-slot="textarea-count".

Accessibility

  • Native <textarea> — focus with Tab; Enter inserts a new line.
  • With Field, id, aria-describedby, aria-invalid and aria-required are wired up automatically.
  • The counter is added to aria-describedby, so screen readers mention the limit when the field gets focus.

On this page