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
| Promise
undefined
validationDebounceTimenumber0
validationMode'onBlur' | 'onChange''onBlur'
AttributeType
data-dirtyEmpty attribute
data-disabledEmpty attribute
data-touchedEmpty attribute

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
AttributeType
data-dirtyEmpty attribute
data-disabledEmpty attribute
data-invalidEmpty attribute
data-touchedEmpty attribute
data-validEmpty attribute

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
AttributeType
data-dirtyEmpty attribute
data-disabledEmpty attribute
data-invalidEmpty attribute
data-touchedEmpty attribute
data-validEmpty attribute

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
AttributeType
data-dirtyEmpty attribute
data-disabledEmpty attribute
data-invalidEmpty attribute
data-touchedEmpty attribute
data-validEmpty attribute

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
AttributeType
data-dirtyEmpty attribute
data-invalidEmpty attribute
data-touchedEmpty attribute
data-validEmpty attribute

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