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 submitteddisabled: Whether the component should ignore user interaction (default:false)validate: A function for custom validation that returns error message(s) ornullvalidationMode: 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 likevalidate()
data-disabled: Present when disableddata-touched: Present when field has been toucheddata-dirty: Present when value has changeddata-valid: Present when field is validdata-invalid: Present when field is invaliddata-filled: Present when field has a valuedata-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 statename: Can override the Field.Root name
Field.Description
Renders descriptive text about the field. Automatically linked to the control viaaria-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 avalidate function that returns error message(s) or null: