Jone

Field

A high-quality, unstyled React field component that provides labeling and validation for form controls.

A component that provides labeling and validation for form controls.

Visible on your profile

Anatomy

Import the component and assemble its parts:

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

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

API reference

Root

NameTypeDefaultDescription
disabledOptionalboolean | undefinedfalseWhether the component should ignore user interaction. Takes precedence over the `disabled` prop on the `<Field.Control>` component.
nameOptionalstring | undefinedIdentifies the field when a form is submitted. Takes precedence over the `name` prop on the `<Field.Control>` component.
valueRequiredunknown,
formValuesRequiredForm.Values,
validationModeOptionalForm.ValidationMode | undefinedonSubmitDetermines when the field should be validated. This takes precedence over the `validationMode` prop on `<Form>`. - `onSubmit`: triggers validation when the form is submitted, and re-validates on change after submission. - `onBlur`: triggers validation when the control loses focus. - `onChange`: triggers validation on every change to the control value.
validationDebounceTimeOptionalnumber | undefined0How long to wait between `validate` callbacks if `validationMode="onChange"` is used. Specified in milliseconds.
invalidOptionalboolean | undefinedWhether the field is invalid. Useful when the field state is controlled by an external library.
dirtyOptionalboolean | undefinedWhether the field's value has been changed from its initial value. Useful when the field state is controlled by an external library.
touchedOptionalboolean | undefinedWhether the field has been touched. Useful when the field state is controlled by an external library.
actionsRefOptionalReact.RefObject<FieldRoot.Actions | null> | undefinedA ref to imperative actions. - `validate`: Validates the field when called.

Label

NameTypeDefaultDescription
nativeLabelOptionalboolean | undefinedtrueWhether the component renders a native `<label>` element when replacing it via the `render` prop. Set to `false` if the rendered element is not a label (e.g. `<div>`). This is useful to avoid inheriting label behaviors on `<button>` controls (such as `<Select.Trigger>` and `<Combobox.Trigger>`), including avoiding `:hover` on the button when hovering the label, and preventing clicks on the label from firing on the button.

Control

NameTypeDefaultDescription
defaultValueOptionalReact.ComponentProps<'input'>['defaultValue'] | undefined

Item

NameTypeDefaultDescription
disabledOptionalboolean | undefinedfalseWhether the wrapped control should ignore user interaction. The `disabled` prop on `<Field.Root>` takes precedence over this.

Error

NameTypeDefaultDescription
matchOptionalboolean | keyof ValidityState | undefinedDetermines whether to show the error message according to the field's [ValidityState](https://developer.mozilla.org/en-US/docs/Web/API/ValidityState). Specifying `true` will always show the error message, and lets external libraries control the visibility.

On this page