# 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**
```ripple
import { Field } from 'ark-ripple/field';
import { Fieldset } from 'ark-ripple/fieldset';
import field from 'styles/field.module.css';
import styles from 'styles/fieldset.module.css';
export component Basic() {
{'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**
```ripple
import { Field } from 'ark-ripple/field';
import { Fieldset } from 'ark-ripple/fieldset';
import field from 'styles/field.module.css';
import styles from 'styles/fieldset.module.css';
export component WithField() {
{'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**
```ripple
import { Checkbox } from 'ark-ripple/checkbox';
import { Fieldset } from 'ark-ripple/fieldset';
import { Check } from 'lucide-ripple';
import checkbox from 'styles/checkbox.module.css';
import styles from 'styles/fieldset.module.css';
export component WithCheckbox() {
{'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**
```ripple
import { Field } from 'ark-ripple/field';
import { Fieldset, useFieldset } from 'ark-ripple/fieldset';
import field from 'styles/field.module.css';
import styles from 'styles/fieldset.module.css';
export component RootProvider() {
const fieldset = useFieldset();
{'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**
```ripple
import { Fieldset } from 'ark-ripple/fieldset';
import { Field } from 'ark-ripple/field';
import { track } from 'ripple';
import { Portal } from 'ark-ripple/portal';
import { Select, createListCollection } from 'ark-ripple/select';
import { ChevronsUpDown } from 'lucide-ripple';
import styles from 'styles/fieldset.module.css';
import field from 'styles/field.module.css';
import select from 'styles/select.module.css';
const extensions = createListCollection(
{
items: [
{ label: '+1', value: '+1' },
{ label: '+44', value: '+44' },
{ label: '+49', value: '+49' },
{ label: '+41', value: '+41' },
],
},
);
export component PhoneInput() {
let inputRef = track(null);
const focusInput = () => {
setTimeout(() => {
@inputRef?.focus();
});
};
{'Mobile Number'}
for (const item of extensions.items; key item.value) {
{item.label}
}
{
@inputRef = el;
return () => {
@inputRef = null;
};
}}
/>
}
```
## API Reference
**Component API Reference**
**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; }; ids: { legend: string; errorText: string; helperText: string; }; disabled: boolean; invalid: boolean; getRootProps: () => Omit<...>; 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. |