# 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.
---
## Anatomy
```tsx
```
## 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
**Example: basic**
#### React
```tsx
import { Field } from '@ark-ui/react/field'
import { Fieldset } from '@ark-ui/react/fieldset'
import field from 'styles/field.module.css'
import styles from 'styles/fieldset.module.css'
export const Basic = () => {
return (
Contact Details
Name
Email
)
}
```
#### Solid
```tsx
import { Field } from '@ark-ui/solid/field'
import { Fieldset } from '@ark-ui/solid/fieldset'
import field from 'styles/field.module.css'
import styles from 'styles/fieldset.module.css'
export const Basic = () => {
return (
Contact Details
Name
Email
)
}
```
#### Vue
```vue
Contact Details
Name
Email
```
#### Svelte
```svelte
Contact Details
Name
Email
```
### 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'
import field from 'styles/field.module.css'
import styles from 'styles/fieldset.module.css'
export const WithField = () => {
return (
Personal Information
First Name
As it appears on your ID
Last Name
)
}
```
#### Solid
```tsx
import { Field } from '@ark-ui/solid/field'
import { Fieldset } from '@ark-ui/solid/fieldset'
import field from 'styles/field.module.css'
import styles from 'styles/fieldset.module.css'
export const WithField = () => {
return (
Personal Information
First Name
As it appears on your ID
Last Name
)
}
```
#### Vue
```vue
Personal Information
First Name
As it appears on your ID
Last Name
```
#### Svelte
```svelte
Personal Information
First Name
As it appears on your ID
Last Name
```
### 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 { Fieldset } from '@ark-ui/react/fieldset'
import { CheckIcon } from 'lucide-react'
import checkbox from 'styles/checkbox.module.css'
import styles from 'styles/fieldset.module.css'
export const WithCheckbox = () => {
return (
Email Preferences
Product updates
Marketing emails
)
}
```
#### Solid
```tsx
import { Checkbox } from '@ark-ui/solid/checkbox'
import { Fieldset } from '@ark-ui/solid/fieldset'
import { CheckIcon } from 'lucide-solid'
import checkbox from 'styles/checkbox.module.css'
import styles from 'styles/fieldset.module.css'
export const WithCheckbox = () => {
return (
Email Preferences
Product updates
Marketing emails
)
}
```
#### Vue
```vue
Email Preferences
Product updates
Marketing emails
```
#### Svelte
```svelte
Email Preferences
Product updates
Marketing emails
```
### Root Provider
An alternative way to control the fieldset is to use the `RootProvider` component and the `useFieldset` hook. This way
you can access the state and methods from outside the component.
**Example: root-provider**
#### React
```tsx
import { Field } from '@ark-ui/react/field'
import { Fieldset, useFieldset } from '@ark-ui/react/fieldset'
import field from 'styles/field.module.css'
import styles from 'styles/fieldset.module.css'
export const RootProvider = () => {
const fieldset = useFieldset()
return (
Contact Details
Name
Email
)
}
```
#### Solid
```tsx
import { Field } from '@ark-ui/solid/field'
import { Fieldset, useFieldset } from '@ark-ui/solid/fieldset'
import field from 'styles/field.module.css'
import styles from 'styles/fieldset.module.css'
export const RootProvider = () => {
const fieldset = useFieldset()
return (
Contact Details
Name
Email
)
}
```
#### Vue
```vue
Contact Details
Name
Email
```
#### Svelte
```svelte
Contact Details
Name
Email
```
### 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 { ChevronsUpDownIcon } from 'lucide-react'
import { useRef } from 'react'
import field from 'styles/field.module.css'
import styles from 'styles/fieldset.module.css'
import select from 'styles/select.module.css'
export const PhoneInput = () => {
const extensions = createListCollection({
items: [
{ label: '+1', value: '+1' },
{ label: '+44', value: '+44' },
{ label: '+49', value: '+49' },
{ label: '+41', value: '+41' },
],
})
const inputRef = useRef(null)
const focusInput = () => {
setTimeout(() => {
inputRef.current?.focus()
})
}
return (
Mobile Number
{extensions.items.map((item) => (
{item.label}
))}
)
}
```
#### 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 { ChevronsUpDownIcon } from 'lucide-solid'
import { Index, createSignal } from 'solid-js'
import { Portal } from 'solid-js/web'
import field from 'styles/field.module.css'
import styles from 'styles/fieldset.module.css'
import select from 'styles/select.module.css'
export const PhoneInput = () => {
const extensions = createListCollection({
items: [
{ label: '+1', value: '+1' },
{ label: '+44', value: '+44' },
{ label: '+49', value: '+49' },
{ label: '+41', value: '+41' },
],
})
const [inputRef, setInputRef] = createSignal(null)
const focusInput = () => {
setTimeout(() => {
inputRef()?.focus()
})
}
return (
Mobile Number
{(item) => (
{item().label}
)}
)
}
```
#### Vue
```vue
Mobile Number
{{ item.label }}
```
#### Svelte
```svelte
Mobile Number
{#each extensions.items as item}
{item.label}
{/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<'legend'>) => 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 | 'true' | 'false'` | 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 | "true" | "false" | 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<'legend'>]>` | 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 | |