StackForm
Components

TextareaField

Multi-line text input field with label, error, hint, character counter, and auto-resize

TextareaField renders a labeled, accessible <textarea> connected to the active form adapter via context. Error and hint states surface automatically — no prop wiring needed.

Be clear and concise.

Props

PropTypeRequiredDefaultDescription
namestringyesField name. Used as the form state key and to derive element IDs.
labelstringLabel text rendered above the textarea.
hintstringHelper text shown below the textarea when no error is present.
placeholderstringPlaceholder text for the textarea.
rowsnumber3Initial number of visible rows.
maxRowsnumberMaximum rows when autoResize is enabled. When reached, scrollbar appears.
maxLengthnumberMaximum character count. Required when showCount is true.
showCountbooleanfalseShows a character counter. Requires maxLength.
autoResizebooleanfalseAutomatically grows/shrinks as content is entered. Use with maxRows to cap height.
resize'none' | 'vertical' | 'horizontal' | 'both''vertical'CSS resize behavior.
disabledbooleanfalseDisables the textarea. Inherits from StackFormProvider if not set.
loadingbooleanfalseReplaces the textarea with a skeleton shimmer.
requiredbooleanfalseMarks the field as required. Appends * to the label.
classNamesTextareaFieldClassNamesTailwind class overrides per slot. Stacks with provider and core classes.
slotsTextareaFieldSlotsComponent overrides per slot. First non-null wins: field → provider → default.
slotProps{ wrapper?, label?, input?, error?, hint?, counter? }Extra props passed to each slot. Field-level replaces provider-level per key.
onValueChange(value: string) => voidCalled after onChange with the new value.
validate(value: string) => string | undefined | Promise<string | undefined>Field-level validator. Runs on blur.

Slots

SlotProp interfaceDescription
WrapperWrapperSlotPropsOuter container element
LabelLabelSlotPropsLabel element
InputTextareaSlotPropsThe <textarea> element
ErrorErrorSlotPropsError message
HintHintSlotPropsHint/helper text
CounterCounterSlotPropsCharacter counter

classNames

KeyApplied to
wrapperOuter container
labelLabel element
inputTextarea element
errorError message
hintHint text
counterCharacter counter

Examples

With error

Errors surface automatically from the form adapter. Trigger one manually to test:

form.setError('notes', { message: 'Notes are required' })

<TextareaField name="notes" label="Notes" />

With hint

<TextareaField
  name="notes"
  label="Notes"
  hint="Add any additional context for your request."
/>

With character counter

<TextareaField
  name="bio"
  label="About you"
  maxLength={500}
  showCount
  placeholder="Tell us about yourself..."
/>

Auto-resize with row cap

Grows as the user types, but stops expanding at maxRows:

<TextareaField
  name="description"
  label="Description"
  placeholder="Enter details..."
  autoResize
  maxRows={8}
/>

Non-resizable

Disable manual resizing by the user:

<TextareaField
  name="notes"
  label="Notes"
  resize="none"
  rows={5}
/>

With slot override

Replace the Label slot with a custom component. Slot components receive only display-level props.

import type { LabelSlotProps } from '@stackform/ui'

function CustomLabel({ htmlFor, children, required }: LabelSlotProps) {
  return (
    <label htmlFor={htmlFor} className="text-sm font-semibold text-blue-600">
      {children}
      {required ? <span aria-hidden="true" className="text-red-500 ml-1"> *</span> : null}
    </label>
  )
}

<TextareaField
  name="feedback"
  label="Feedback"
  slots={{ Label: CustomLabel }}
/>