Field

A component that provides labelling and validation for form controls.

Visible on your profile

API reference

Import the component and assemble its parts:

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
name

string

undefined

disabled

boolean

false

invalid

boolean

undefined

validate

(value) => string | string[] | null | Promise

undefined

validationMode

'onBlur' | 'onChange'

'onBlur'

validationDebounceTime

number

0

className

string | (state) => string

undefined

render

| React.ReactElement
| (props, state) => React.ReactElement

undefined

Attribute
Description
data-disabled
data-dirty
data-touched

Label

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

PropTypeDefault
className

string | (state) => string

undefined

render

| React.ReactElement
| (props, state) => React.ReactElement

undefined

Attribute
Description
data-disabled
data-valid
data-invalid
data-dirty
data-touched

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
onValueChange

(value, event) => void

undefined

className

string | (state) => string

undefined

render

| React.ReactElement
| (props, state) => React.ReactElement

undefined

Attribute
Description
data-disabled
data-valid
data-invalid
data-dirty
data-touched

Description

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

PropTypeDefault
className

string | (state) => string

undefined

render

| React.ReactElement
| (props, state) => React.ReactElement

undefined

Attribute
Description
data-disabled
data-valid
data-invalid
data-dirty
data-touched

Error

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

PropTypeDefault
match

| 'badInput'
| 'customError'
| 'patternMismatch'
| 'rangeOverflow'
| 'rangeUnderflow'
| 'stepMismatch'
| 'tooLong'
| 'tooShort'
| 'typeMismatch'
| 'valid'
| 'valueMissing'

undefined

forceShow

boolean

undefined

className

string | (state) => string

undefined

render

| React.ReactElement
| (props, state) => React.ReactElement

undefined

Attribute
Description
data-valid
data-invalid
data-dirty
data-touched

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.ReactNode

undefined