Field
Provides a flexible container for form inputs, labels, and helper text.
Anatomy
<Field.Root>
<Field.Label>
<Field.Indicator />
</Field.Label>
<Field.Input />
<Field.Textarea />
<Field.Select />
<Field.HelperText />
<Field.ErrorText />
</Field.Root>
Examples
Field provides invalid, disabled, required, and readOnly context to form elements. Most Ark UI components read
it natively, and it also works with standard HTML form elements.
Input
Use Field.Input for a standard input.
Disabled
Set disabled on the root to disable the control and mark every part with data-disabled.
Invalid
Set invalid to show the error text and mark the control with aria-invalid. The error text stays mounted and hidden
while the field is valid.
Indicator
Field.Indicator is shown only when its type matches the field state: required, invalid, valid or validating.
Use it inside the label to show a required marker.
Validation
The field validates the control natively, using attributes like required and type="email". Set validationMode to
choose when results show (onSubmit, onBlur or onChange). Pass match to Field.ErrorText to show it only for one
native failure, such as valueMissing or typeMismatch.
Custom Validation
Pass validate to run your own rules. Return an error message, a list of messages, or nothing when the value is valid.
It can also return a promise. The messages are available as errors on the field context.
Server Errors
Pass errors to show errors from outside the field, such as a server response. The field is invalid while errors is
not empty.
Textarea
Use Field.Textarea for a textarea.
Textarea Autoresize
Set autoresize on Field.Textarea to grow it as the user types.
Select
Use Field.Select for a native select.
Checkbox
Wrap a Checkbox in Field.
Root Provider
Use RootProvider with the useField hook to access the state and methods from outside the component.
Custom Control
Use Field.Context or the useFieldContext hook to read the field state and wire up a custom control.
API Reference
Root
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
dirty | booleanWhether the field's value has been changed from its initial value. Useful when the field state is controlled by an external library. | |
disabled | false | booleanWhether the field is disabled. Also inherited from a surrounding native `<fieldset disabled>`. |
errors | string | string[]Errors from outside the field, such as a server response. They mark the field invalid until the user changes the value, and show again when different errors are passed or the form is submitted. | |
ids | Partial<{ root: string; control: string; label: string; errorText: string; helperText: string }>The ids of the elements. Useful for composition. | |
invalid | booleanWhether the field is invalid, regardless of computed validity. Use for app-level errors (e.g. server errors) the machine cannot compute itself. | |
onValidityChange | (details: ValidityChangeDetails) => voidCalled when the committed validity changes. | |
readOnly | false | booleanWhether the field is read-only. |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<FieldRootState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. | |
required | false | booleanWhether the field is required. |
target | stringThe item whose control the field tracks, for fields composed of multiple controls. The tracked control id (and the root label's `htmlFor`) become `{id}:item:{target}`. `ids.control` overrides this. | |
touched | booleanWhether the field has been touched. Useful when the field state is controlled by an external library. | |
validate | (details: ValidateDetails) => ValidateResult | Promise<ValidateResult>Custom validation, run against the value and the native validity snapshot. May return a promise; a newer validation run supersedes an in-flight one. | |
validationMode | 'onSubmit' | ValidationModeWhen validation results become visible. |
ErrorText
Defines the <span> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
id | stringOverrides the generated id. Use when two error texts share the same `match`. | |
match | boolean | ValidityMatchNarrows when the error text shows: - a `ValidityState` key shows it only for that native failure - `true` forces it visible (e.g. driven by an external form library) - omitted shows it whenever the field is invalid | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<FieldErrorTextState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
HelperText
Defines the <span> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<FieldHelperTextState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
Indicator
Defines the <span> element.
| Attribute | Default | Type |
|---|---|---|
type | IndicatorTypeThe state the indicator reflects. Hidden (not unmounted) unless the state matches, so CSS transitions survive: - `required`: the field is required (e.g. an asterisk) - `invalid`: committed validity is invalid - `valid`: committed validity is valid — a pristine field shows neither - `validating`: an async validation is in flight (e.g. a spinner) | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<FieldIndicatorState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
Input
Defines the <input> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<FieldInputState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
Item
| Prop | Default | Type |
|---|---|---|
value | string |
Label
Defines the <label> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<FieldLabelState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
RootProvider
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
value | UseFieldReturn | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<FieldRootProviderState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
Select
Defines the <select> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<FieldSelectState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
Textarea
Defines the <textarea> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
autoresize | false | booleanWhether the textarea should autoresize |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<FieldTextareaState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |