Field

A component that provides labelling and validation for form controls.

Visible on your profile

API reference

Import the component and place its parts the following way:

Anatomy
import { Field } from '@base-ui-components/react/field';

<Field.Root>
  <Field.Label />
  <Field.Control />
  <Field.Description />
  <Field.Error />
  <Field.Validity />
</Field.Root>

Root

Groups all parts of the field. Renders a <div> element.

PropTypeDefault
classNamestring | (state) => stringundefined
disabledbooleanfalse
invalidbooleanundefined
namestringundefined
render| React.ReactElement
| (props, state) => React.ReactElement
undefined
validate(value) => string | string[] | null | Promiseundefined
validationDebounceTimenumber0
validationMode'onBlur' | 'onChange''onBlur'
Attribute
Description
data-dirty
data-disabled
data-touched

Label

An accessible label that is automatically associated with the field control. Renders a <label> element.

PropTypeDefault
classNamestring | (state) => stringundefined
render| React.ReactElement
| (props, state) => React.ReactElement
undefined
Attribute
Description
data-dirty
data-disabled
data-invalid
data-touched
data-valid

Control

The form control to label and validate. Renders an <input> element.

You can omit this part and use any Base UI input component instead. For example, Input, Checkbox, or Select, among others, will work with Field out of the box.

PropTypeDefault
classNamestring | (state) => stringundefined
onValueChange(value, event) => voidundefined
render| React.ReactElement
| (props, state) => React.ReactElement
undefined
Attribute
Description
data-dirty
data-disabled
data-invalid
data-touched
data-valid

Description

A paragraph with additional information about the field. Renders a <p> element.

PropTypeDefault
classNamestring | (state) => stringundefined
render| React.ReactElement
| (props, state) => React.ReactElement
undefined
Attribute
Description
data-dirty
data-disabled
data-invalid
data-touched
data-valid

Error

An error message displayed if the field control fails validation. Renders a <div> element.

PropTypeDefault
classNamestring | (state) => stringundefined
forceShowbooleanundefined
match| 'badInput'
| 'customError'
| 'patternMismatch'
| 'rangeOverflow'
| 'rangeUnderflow'
| 'stepMismatch'
| 'tooLong'
| 'tooShort'
| 'typeMismatch'
| 'valid'
| 'valueMissing'
undefined
render| React.ReactElement
| (props, state) => React.ReactElement
undefined
Attribute
Description
data-dirty
data-invalid
data-touched
data-valid

Validity

Used to display a custom message based on the fieldโ€™s validity. Requires children to be a function that accepts field validity state as an argument.

PropTypeDefault
children(validity) => React.ReactNodeundefined