Field

Provides a flexible container for form inputs, labels, and helper text.

Loading...

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.

AttributeDefaultType
asChild
boolean

Use 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
boolean

Whether the field's value has been changed from its initial value. Useful when the field state is controlled by an external library.

disabledfalse
boolean

Whether 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
boolean

Whether 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) => void

Called when the committed validity changes.

readOnlyfalse
boolean

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

requiredfalse
boolean

Whether the field is required.

target
string

The 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
boolean

Whether 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'
ValidationMode

When validation results become visible.

ErrorText

Defines the <span> element.

AttributeDefaultType
asChild
boolean

Use 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
string

Overrides the generated id. Use when two error texts share the same `match`.

match
boolean | ValidityMatch

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

AttributeDefaultType
asChild
boolean

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

AttributeDefaultType
type
IndicatorType

The 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
boolean

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

AttributeDefaultType
asChild
boolean

Use 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

PropDefaultType
value
string

Label

Defines the <label> element.

AttributeDefaultType
asChild
boolean

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

AttributeDefaultType
value
UseFieldReturn

asChild
boolean

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

AttributeDefaultType
asChild
boolean

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

AttributeDefaultType
asChild
boolean

Use 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.
autoresizefalse
boolean

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