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.Control />
<Field.Label />
<Field.Description />
<Field.Error />
<Field.Validity />
</Field.Root>
Root
The foundation for building custom-styled fields.
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
disabled | boolean | false | |
invalid | boolean | undefined | |
name | string | undefined | |
render | | React.ReactElement | undefined | |
validate | | (value) => string | undefined | |
validationDebounceTime | number | 0 | |
validationMode | 'onBlur' | 'onChange' | 'onBlur' |
Label
A label for the field's control.
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
render | | React.ReactElement | undefined |
Description
A description message for the field's control.
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
render | | React.ReactElement | undefined |
Error
Displays error messages for the field's control.
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
forceShow | boolean | undefined | |
match | | 'badInput' | undefined | |
render | | React.ReactElement | undefined |
Control
The field's control element. This is not necessary to use when using a native Base UI input component (Checkbox, Switch, NumberField, Slider, Radio Group etc).
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
onValueChange | (value, event) => void | undefined | |
render | | React.ReactElement | undefined |
Validity
Render prop component that provides the field's validity state and value to its children.
Prop | Type | Default | |
---|---|---|---|
children | (validity) => React.ReactNode | undefined |