Umbra UI

FormField

Label, description and error wiring for any control.

Staticimport { FormField } from 'umbra-ui'

Props

PropTypeDefaultDescription
children requiredReactNode—A single Umbra control (Input, Textarea, Select, Checkbox, RadioGroup, Switch).
label requiredReactNode—Visible label, associated with the control.
controlId string—Id for the control. Generated when omitted.
description ReactNode—Helper text shown under the control and announced with it.
disabled booleanfalseDisables the control and dims the label.
error ReactNode—Error message. When set the field is invalid and the message is announced.
required booleanfalseMarks the control as required and shows an indicator next to the label.

Usage notes

Wrap exactly one Umbra control. It receives its id, aria-describedby, aria-invalid, required and disabled through context; props set on the control win.

Accessibility

  • <label for> is wired to the control; group controls get aria-labelledby.
  • Description and error are both referenced by aria-describedby, error first.
  • The error container is an aria-live="polite" region, so new errors are announced.
  • The required asterisk is decorative; the control gets required.

Import

import { FormField } from 'umbra-ui';
import 'umbra-ui/styles.css'; // once, at the root of your app