Field
Provides a flexible container for form inputs, labels, and helper text.
Examples
The Field component provides contexts such as invalid, disabled, required, and readOnly for form elements.
While most Ark UI components natively support these contexts, you can also use the Field component with standard HTML
form elements.
Input
This example shows how to use the Field component with a standard input field.
Example not foundExample not foundExample not foundExample not foundTextarea
This example illustrates how to use the Field component with a textarea element.
Example not foundExample not foundExample not foundExample not foundTextarea Autoresize
Pass the autoresize prop to the Textarea component to enable automatic resizing as the user types.
Example not foundExample not foundExample not foundExample not foundSelect
This example demonstrates how to integrate the Field component with a select dropdown.
Example not foundExample not foundExample not foundExample not foundCheckbox
This example demonstrates how to integrate the Field and Checkbox components.
Example not foundExample not foundExample not foundExample not foundRoot Provider
Use the useField hook to create the field store and pass it to the Field.RootProvider component. This allows you to
have maximum control over the field programmatically.
Example not foundExample not foundExample not foundExample not foundIf you're using the
Field.RootProvidercomponent, you don't need to use theField.Rootcomponent.
Custom Control
Use the Field.Context or useFieldContext hook to access the internal state of the field.This can help you wire up
custom controls with the Field component.
Example not foundExample not foundExample not foundExample not foundAPI Reference
Root
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. | |
disabled | booleanIndicates whether the field is disabled. | |
ids | ElementIdsThe ids of the field parts. | |
invalid | booleanIndicates whether the field is invalid. | |
readOnly | booleanIndicates whether the field is read-only. | |
required | booleanIndicates whether the field is required. |
ErrorText
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
HelperText
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
Input
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
Label
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
RequiredIndicator
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. | |
fallback | string | number | bigint | boolean | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | Promise<...> |
RootProvider
| Prop | Default | Type |
|---|---|---|
value | { ariaDescribedby: string | undefined; ids: { root: string; control: string; label: string; errorText: string; helperText: string; }; refs: { rootRef: RefObject<HTMLDivElement | null>; }; ... 11 more ...; getRequiredIndicatorProps: () => Omit<...>; } | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
Select
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
Textarea
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. | |
autoresize | false | booleanWhether the textarea should autoresize |