Skip to content

Textarea

A labeled multi-line text area with configurable resize behavior, including an auto-grow mode, plus description and inline error.

Import

import { Textarea } from "@hyzer-labs/ui"

Demo

let notes = $state('');

<Textarea name="notes" label="Round notes" bind:value={notes} />

Props

NameTypeDefaultNote
namestringRequired. Form field name.
labelstringRequired. Always in the DOM; sr-only with hideLabel.
valuestring''Bindable.
rowsnumber3
resize'none' | 'vertical' | 'both' | 'auto''vertical''vertical' and 'auto' grow with content; 'vertical' keeps the drag handle, 'auto' hides it. rows is the minimum height.
maxlengthnumber
descriptionstringHelp text below the label.
errorstringInline error message; sets the error state.
requiredbooleanfalse
disabledbooleanfalse
hideLabelbooleanfalse
classstringMerged after the hz-field class.

Theme hooks

What this component promises your CSS. The reference theme styles exactly these — from @layer hz-theme, so your unlayered rules win. See Styling Components for the how.

Root class: .hz-field

Data attributes

HookValuesStyles
data-state'default' | 'error' | 'disabled'The universal field state hook, on the root. Precedence is fixed: error beats disabled.
data-resize'none' | 'vertical' | 'both' | 'auto'On the textarea. Default vertical; auto uses field-sizing: content.

Part classes

HookValuesStyles
.hz-field-labelchild elementThe label.
.hz-field-requiredchild elementThe required marker.
.hz-field-descriptionchild elementThe hint text.
.hz-field-errorchild elementThe error message.

Accessibility

The textarea is associated with its label via id/for. With hideLabel, the label stays in the DOM as screen-reader-only text.

description and error chain into aria-describedby, description first. required sets aria-required, and an error sets aria-invalid.

References: MDN: <textarea>