Field
A component that provides labelling and validation for form controls.
Visible on your profile
API reference
Import the component and assemble its parts:
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.
Prop | Type | Default | |
---|---|---|---|
name |
|
| |
disabled |
|
| |
invalid |
|
| |
validate |
|
| |
validationMode |
|
| |
validationDebounceTime |
|
| |
className |
|
| |
render |
|
|
Attribute | Description | |
---|---|---|
data-disabled | Present when the field is disabled. | |
data-dirty | Present when the field's value has changed. | |
data-touched | Present when the field has been touched. |
Label
An accessible label that is automatically associated with the field control.
Renders a <label>
element.
Prop | Type | Default | |
---|---|---|---|
className |
|
| |
render |
|
|
Attribute | Description | |
---|---|---|
data-disabled | Present when the field is disabled. | |
data-valid | Present when the field is in valid state. | |
data-invalid | Present when the field is in invalid state. | |
data-dirty | Present when the field's value has changed. | |
data-touched | Present when the field has been 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.
Prop | Type | Default | |
---|---|---|---|
onValueChange |
|
| |
className |
|
| |
render |
|
|
Attribute | Description | |
---|---|---|
data-disabled | Present when the field is disabled. | |
data-valid | Present when the field is in valid state. | |
data-invalid | Present when the field is in invalid state. | |
data-dirty | Present when the field's value has changed. | |
data-touched | Present when the field has been touched. |
Description
A paragraph with additional information about the field.
Renders a <p>
element.
Prop | Type | Default | |
---|---|---|---|
className |
|
| |
render |
|
|
Attribute | Description | |
---|---|---|
data-disabled | Present when the field is disabled. | |
data-valid | Present when the field is in valid state. | |
data-invalid | Present when the field is in invalid state. | |
data-dirty | Present when the field's value has changed. | |
data-touched | Present when the field has been touched. |
Error
An error message displayed if the field control fails validation.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
match |
|
| |
forceShow |
|
| |
className |
|
| |
render |
|
|
Attribute | Description | |
---|---|---|
data-valid | Present when the field is in valid state. | |
data-invalid | Present when the field is in invalid state. | |
data-dirty | Present when the field's value has changed. | |
data-touched | Present when the field has been 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.
Prop | Type | Default | |
---|---|---|---|
children |
|
|