The Field component extends Base UI's Field. It is an essential building block for text inputs, providing labels, descriptions, and most importantly, validation and error display management. Fields will be typically used within a Form component that coordinates across multiple Fields.
Installation
Here is the component implementation code that you can copy to your project:
Compose fields by combining subcomponents: a standalone input, an input with a label, a complete field with description, or a field displaying an error state. Labels are automatically associated with inputs for accessibility.
Description text
Error message
Basic validation with HTML constraints
You can use native HTML5 validation attributes like required, minLength, pattern, and type. Use Field.Error with the match prop to display messages based on the browser's ValidityState.
Standard client-side input validation
For most cases, the best way to add client-side input validation is to use the validate prop on Field.Root. This allows you to define custom validation rules for each input:
validate — A function that receives the input value and returns an error message string (or array of strings), or null if valid. Supports async functions for server-side checks.
validationMode — Determines when validation runs: "onSubmit" (default, validates on form submit and revalidates on change after), "onBlur" (validates when the input loses focus), or "onChange" (validates on every change).
↓ validationMode="onChange" — validates as you type
↓ validationMode="onBlur" — validates when you leave the field
↓ validationMode="onSubmit" — validates on form submission
Server-side validation and Forms
Typically, Fields are orchestrated within a Form component, allowing you to set up an onFormSubmit callback that triggers client-side or server-side validation. For advanced form state management, Base UI integrates seamlessly with TanStack Form and React Hook Form.