Skip to main content
The Field component provides validation, error handling, and accessibility features for form inputs.

Import

Basic Usage

Sub-components

Field.Root

Groups all parts of the field. Renders a <div> element. Key Props:
  • name: Identifies the field when a form is submitted
  • disabled: Whether the component should ignore user interaction (default: false)
  • validate: A function for custom validation that returns error message(s) or null
  • validationMode: When to validate - 'onSubmit' | 'onBlur' | 'onChange' (default: 'onSubmit')
  • validationDebounceTime: Debounce time in milliseconds for onChange validation (default: 0)
  • invalid: Whether the field is invalid (for external control)
  • dirty: Whether the field value has changed from initial value (for external control)
  • touched: Whether the field has been touched (for external control)
  • actionsRef: Ref to imperative actions like validate()
State attributes:
  • data-disabled: Present when disabled
  • data-touched: Present when field has been touched
  • data-dirty: Present when value has changed
  • data-valid: Present when field is valid
  • data-invalid: Present when field is invalid
  • data-filled: Present when field has a value
  • data-focused: Present when field is focused

Field.Label

Renders a <label> element associated with the control.

Field.Control

The input control element. Renders a native <input> by default. Props:
  • Accepts all standard input attributes (type, placeholder, required, etc.)
  • disabled: Can override the Field.Root disabled state
  • name: Can override the Field.Root name

Field.Description

Renders descriptive text about the field. Automatically linked to the control via aria-describedby.

Field.Error

Displays error messages based on validation state. Key Props:
  • match: Which validation error to display. Can be:
    • 'badInput' | 'customError' | 'patternMismatch' | 'rangeOverflow' | 'rangeUnderflow' | 'stepMismatch' | 'tooLong' | 'tooShort' | 'typeMismatch' | 'valueMissing'
    • A function: (errors, value) => boolean
  • forceShow: Force error to display regardless of field state

Field.Validity

Accesses the field’s validity data programmatically (render prop pattern).

Field.Item

Used for grouping multiple controls within a single field (e.g., radio buttons, checkboxes).

Validation

Built-in Validation

The Field component automatically validates based on native HTML5 constraints:

Custom Validation

Provide a validate function that returns error message(s) or null:

Async Validation

Async validation functions are supported:

Validation Modes

Styling

Imperative API

Trigger validation programmatically: