# Fieldset
URL: https://ark-ui.com/docs/components/fieldset
Source: https://raw.githubusercontent.com/chakra-ui/ark/refs/heads/main/website/src/content/pages/components/fieldset.mdx
A set of form controls optionally grouped under a common name.
---
## Examples
The `Fieldset` component provides contexts such as `invalid` and `disabled` for form elements. While most Ark UI
components natively support these contexts, you can also use the `Field` component with standard HTML form elements.
### Basic Usage
Learn how to use the `Fieldset` component in your project. Let's take a look at the most basic example:
**Example: basic**
#### React
```tsx
import { Field } from '@ark-ui/react/field'
import { Fieldset } from '@ark-ui/react/fieldset'
export const Basic = () => {
return (
LegendHelper textError text
)
}
```
#### Solid
```tsx
import { Field } from '@ark-ui/solid/field'
import { Fieldset } from '@ark-ui/solid/fieldset'
export const Basic = () => {
return (
LegendHelper textError text
)
}
```
#### Vue
```vue
LegendHelper textError text
```
#### Svelte
```svelte
LegendHelper textError text
```
### Field
This example demonstrates how to use the `Field` component with a standard input field within a `Fieldset`.
**Example: with-field**
#### React
```tsx
import { Field } from '@ark-ui/react/field'
import { Fieldset } from '@ark-ui/react/fieldset'
export const WithField = () => {
return (
LegendFieldset Helper TextFieldset Error TextLabelField Helper TextField Error Text
)
}
```
#### Solid
```tsx
import { Field } from '@ark-ui/solid/field'
import { Fieldset } from '@ark-ui/solid/fieldset'
export const WithField = () => {
return (
LegendFieldset Helper TextFieldset Error TextLabelField Helper TextField Error Text
)
}
```
#### Vue
```vue
LegendFieldset Helper TextFieldset Error TextLabelField Helper TextField Error Text
```
#### Svelte
```svelte
Personal InformationFirst NameLast NameEmailWe'll never share your emailPlease fill out all required fields
```
### Checkbox
This example shows how to use the `Fieldset` component with other Ark UI form elements like `Checkbox`.
**Example: with-checkbox**
#### React
```tsx
import { Checkbox } from '@ark-ui/react/checkbox'
import { Field } from '@ark-ui/react/field'
import { Fieldset } from '@ark-ui/react/fieldset'
export const WithCheckbox = () => {
return (
LegendFieldset Helper TextFieldset Error TextLabel✔️Field Heler TextField Error Text
)
}
```
#### Solid
```tsx
import { Checkbox } from '@ark-ui/solid/checkbox'
import { Field } from '@ark-ui/solid/field'
import { Fieldset } from '@ark-ui/solid/fieldset'
export const WithCheckbox = () => {
return (
LegendFieldset Helper TextFieldset Error TextLabel✔️Field Heler TextField Error Text
)
}
```
#### Vue
```vue
LegendFieldset Helper TextFieldset Error TextCheckbox✔️Field Heler TextField Error Text
```
#### Svelte
```svelte
LegendHelper textError textLabel✔️Field Heler TextField Error Text
```
### Root Provider
The `RootProvider` component provides a context for the fieldset. It accepts the value of the `useFieldset` hook. You
can leverage it to access the component state and methods from outside the fieldset.
**Example: root-provider**
#### React
```tsx
import { Fieldset, useFieldset } from '@ark-ui/react/fieldset'
export const RootProvider = () => {
const fieldset = useFieldset({
disabled: true,
})
return (
LegendHelper textError text
)
}
```
#### Solid
```tsx
import { Fieldset, useFieldset } from '@ark-ui/solid/fieldset'
export const RootProvider = () => {
const fieldset = useFieldset({
disabled: true,
})
return (
LegendHelper textError text
)
}
```
#### Vue
```vue
Contact Information
Please fill out all required fields
```
#### Svelte
```svelte
External State ManagementManaged by external fieldset state
{#snippet render(fieldset)}
Fieldset disabled: {fieldset().disabled}
Fieldset invalid: {fieldset().invalid}
{/snippet}
```
> If you're using the `RootProvider` component, you don't need to use the `Root` component.
### Input with Select
This example shows how to use the `Fieldset` component with `Field.Input` and `Select` to create a interactive phone
input component.
**Example: phone-input**
#### React
```tsx
import { Field } from '@ark-ui/react/field'
import { Fieldset } from '@ark-ui/react/fieldset'
import { Portal } from '@ark-ui/react/portal'
import { Select, createListCollection } from '@ark-ui/react/select'
import { useRef } from 'react'
export const PhoneInput = () => {
const extensions = createListCollection({
items: ['+1', '+44', '+49', '+41'],
})
const inputRef = useRef(null)
const focusInput = () => {
setTimeout(() => {
inputRef.current?.focus()
})
}
return (
Mobile Number
{extensions.items.map((item) => (
{item}
))}
)
}
```
#### Solid
```tsx
import { Field } from '@ark-ui/solid/field'
import { Fieldset } from '@ark-ui/solid/fieldset'
import { Select, createListCollection } from '@ark-ui/solid/select'
import { Index, createSignal } from 'solid-js'
import { Portal } from 'solid-js/web'
export const PhoneInput = () => {
const extensions = createListCollection({
items: ['+1', '+44', '+49', '+41'],
})
const [inputRef, setInputRef] = createSignal(null)
const focusInput = () => {
setTimeout(() => {
inputRef()?.focus()
})
}
return (
Mobile Number
{(item) => (
{item()}
)}
)
}
```
#### Vue
```vue
Mobile Number
{{ item }}
```
#### Svelte
```svelte
Mobile Number
{#each extensions.items as item}
{item}
{/each}
```
## API Reference
**Component API Reference**
#### React
**Root Props:**
| Prop | Type | Required | Description |
|------|------|----------|-------------|
| `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. |
| `invalid` | `boolean` | No | Indicates whether the fieldset is invalid. |
**ErrorText Props:**
| Prop | Type | Required | Description |
|------|------|----------|-------------|
| `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. |
**HelperText Props:**
| Prop | Type | Required | Description |
|------|------|----------|-------------|
| `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. |
**Legend Props:**
| Prop | Type | Required | Description |
|------|------|----------|-------------|
| `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. |
**RootProvider Props:**
| Prop | Type | Required | Description |
|------|------|----------|-------------|
| `value` | `{ refs: { rootRef: RefObject; }; disabled: boolean; invalid: boolean; getRootProps: () => Omit, HTMLFieldSetElement>, "ref">; getLegendProps: () => Omit<...>; getHelperTextProps: () => Omit<...>; getErrorTextProps: () => Omit<....` | Yes | |
| `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. |
#### Solid
**Root Props:**
| Prop | Type | Required | Description |
|------|------|----------|-------------|
| `asChild` | `(props: ParentProps<'fieldset'>) => Element` | No | Use the provided child element as the default rendered element, combining their props and behavior. |
| `invalid` | `boolean` | No | Indicates whether the fieldset is invalid. |
**ErrorText Props:**
| Prop | Type | Required | Description |
|------|------|----------|-------------|
| `asChild` | `(props: ParentProps<'span'>) => Element` | No | Use the provided child element as the default rendered element, combining their props and behavior. |
**HelperText Props:**
| Prop | Type | Required | Description |
|------|------|----------|-------------|
| `asChild` | `(props: ParentProps<'span'>) => Element` | No | Use the provided child element as the default rendered element, combining their props and behavior. |
**Legend Props:**
| Prop | Type | Required | Description |
|------|------|----------|-------------|
| `asChild` | `(props: ParentProps<'div'>) => Element` | No | Use the provided child element as the default rendered element, combining their props and behavior. |
**RootProvider Props:**
| Prop | Type | Required | Description |
|------|------|----------|-------------|
| `value` | `Accessor<{ refs: { rootRef: HTMLFieldSetElement | undefined; }; disabled: boolean; invalid: boolean; getRootProps: () => { disabled: boolean; 'data-disabled': boolean | "true" | "false"; ... 4 more ...; "data-part": string; }; getLegendProps: () => { ...; }; getHelperTextProps: () => { ...; }; getErrorTextProps: () ...` | Yes | |
| `asChild` | `(props: ParentProps<'fieldset'>) => Element` | No | Use the provided child element as the default rendered element, combining their props and behavior. |
#### Vue
**Root Props:**
| Prop | Type | Required | Description |
|------|------|----------|-------------|
| `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. |
| `disabled` | `boolean | 'false' | 'true'` | No | Indicates whether the fieldset is disabled. |
| `id` | `string` | No | The id of the fieldset. |
| `invalid` | `boolean` | No | Indicates whether the fieldset is invalid. |
**ErrorText Props:**
| Prop | Type | Required | Description |
|------|------|----------|-------------|
| `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. |
**HelperText Props:**
| Prop | Type | Required | Description |
|------|------|----------|-------------|
| `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. |
**Legend Props:**
| Prop | Type | Required | Description |
|------|------|----------|-------------|
| `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. |
**RootProvider Props:**
| Prop | Type | Required | Description |
|------|------|----------|-------------|
| `value` | `{ refs: { rootRef: Ref; }; disabled: boolean | "false" | "true" | undefined; invalid: boolean | undefined; getRootProps: () => FieldsetHTMLAttributes; getLegendProps: () => { ...; }; getHelperTextProps: () => { ...; }; getErrorTextProps: () => HTMLAttributes; }` | Yes | |
| `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. |
#### Svelte
**Root Props:**
| Prop | Type | Required | Description |
|------|------|----------|-------------|
| `asChild` | `Snippet<[PropsFn<'fieldset'>]>` | No | Use the provided child element as the default rendered element, combining their props and behavior. |
| `disabled` | `boolean` | No | Indicates whether the fieldset is disabled. |
| `id` | `string` | No | The id of the fieldset. |
| `invalid` | `boolean` | No | Indicates whether the fieldset is invalid. |
| `ref` | `Element` | No | |
**Context Props:**
| Prop | Type | Required | Description |
|------|------|----------|-------------|
| `render` | `Snippet<[() => { setRootRef: (el: Element | null) => void; disabled: boolean; invalid: boolean; getRootProps: () => HTMLFieldsetAttributes; getLegendProps: () => HTMLAttributes<...>; getHelperTextProps: () => HTMLAttributes<...>; getErrorTextProps: () => HTMLAttributes<...>; }]>` | Yes | |
**ErrorText Props:**
| Prop | Type | Required | Description |
|------|------|----------|-------------|
| `asChild` | `Snippet<[PropsFn<'span'>]>` | No | Use the provided child element as the default rendered element, combining their props and behavior. |
| `ref` | `Element` | No | |
**HelperText Props:**
| Prop | Type | Required | Description |
|------|------|----------|-------------|
| `asChild` | `Snippet<[PropsFn<'span'>]>` | No | Use the provided child element as the default rendered element, combining their props and behavior. |
| `ref` | `Element` | No | |
**Legend Props:**
| Prop | Type | Required | Description |
|------|------|----------|-------------|
| `asChild` | `Snippet<[PropsFn<'div'>]>` | No | Use the provided child element as the default rendered element, combining their props and behavior. |
| `ref` | `Element` | No | |
**RootProvider Props:**
| Prop | Type | Required | Description |
|------|------|----------|-------------|
| `value` | `() => { setRootRef: (el: Element | null) => void; disabled: boolean; invalid: boolean; getRootProps: () => HTMLFieldsetAttributes; getLegendProps: () => HTMLAttributes<...>; getHelperTextProps: () => HTMLAttributes<...>; getErrorTextProps: () => HTMLAttributes<...>; }` | Yes | |
| `asChild` | `Snippet<[PropsFn<'fieldset'>]>` | No | Use the provided child element as the default rendered element, combining their props and behavior. |
| `ref` | `Element` | No | |