Fieldset
A set of form controls optionally grouped under a common name.
Anatomy
<Fieldset.Root>
<Fieldset.Legend />
<Fieldset.HelperText />
<Fieldset.ErrorText />
</Fieldset.Root>
Examples
Fieldset provides invalid and disabled context to the fields inside it. Most Ark UI components read it natively.
Use Field to apply it to standard HTML form elements.
Basic
Disabled
Set disabled to disable every field inside, including fields without a control.
Invalid
Set invalid to show the fieldset error text next to each field's errors.
Field
Use Field with a standard input inside a Fieldset.
Checkbox
Use Fieldset with Ark UI form components like Checkbox.
Root Provider
Use RootProvider with the useFieldset hook to access the state and methods from outside the component.
Input with Select
Combine Field.Input and Select in a Fieldset to build a phone input.
API Reference
Root
Defines the <fieldset> 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. | |
ids | Partial<{ root: string; legend: string; errorText: string; helperText: string }>The ids of the elements. Useful for composition. | |
invalid | false | booleanWhether the fieldset is invalid. Not inherited by descendant fields, but their controls are described by the fieldset's error text. |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<FieldsetRootState>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. |
| Attribute | Description |
|---|---|
[data-fieldset-root] | <uid> |
[data-disabled] | Present when disabled |
[data-invalid] | Present when invalid |
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. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<FieldsetErrorTextState>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. |
| Attribute | Description |
|---|---|
[data-fieldset-error-text] | <uid> |
[data-disabled] | Present when disabled |
[data-invalid] | Present when invalid |
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<FieldsetHelperTextState>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. |
| Attribute | Description |
|---|---|
[data-fieldset-helper-text] | <uid> |
[data-disabled] | Present when disabled |
[data-invalid] | Present when invalid |
Legend
Defines the <legend> 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<FieldsetLegendState>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. |
| Attribute | Description |
|---|---|
[data-fieldset-legend] | <uid> |
[data-disabled] | Present when disabled |
[data-invalid] | Present when invalid |
RootProvider
Defines the <fieldset> element.
| Attribute | Default | Type |
|---|---|---|
value | UseFieldsetReturn | |
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<FieldsetRootProviderState>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. |