---
title: Fieldset
description: "`Fieldset` is a component used to group elements such as legends, helper messages, and error messages in a fieldset element."
links:
- style: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/fieldset/fieldset.style.ts
- source: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/fieldset
- storybook: https://yamada-ui.github.io/yamada-ui?path=/story/components-fieldset--basic
---
# Fieldset
`Fieldset` is a component used to group elements such as legends, helper messages, and error messages in a fieldset element.
```tsx
```
## Usage
```tsx
import { Fieldset } from "@yamada-ui/react"
```
```tsx
import { Fieldset } from "@/components/ui"
```
```tsx
import { Fieldset } from "@workspaces/ui"
```
```tsx
```
### Change Variant
```tsx
{(variant, index) => (
)}
```
### Change Size
```tsx
{(size, index) => (
)}
```
### Displaying a Helper Message
To display a helper message, set a `ReactNode` to `helperMessage`.
```tsx
```
Alternatively, you can customize using `Fieldset.HelperMessage`.
```tsx
Please provide your contact details below.
```
### Displaying an Error Message
To display an error message, set `invalid` to `true` and assign a `ReactNode` to `errorMessage`.
```tsx
```
Alternatively, you can customize using `Fieldset.ErrorMessage`.
```tsx
Some fields are invalid. Please check them.
```
### Required
To make it required, set `required` to `true`.
```tsx
```
### Disable
To disable, set `disabled` to `true`.
```tsx
```
### Read-Only
To make it read-only, set `readOnly` to `true`.
```tsx
```
### Invalid
To make the input invalid, set `invalid` to `true`.
```tsx
```
### Customize the Legend
To customize the legend, use `Fieldset.Legend`.
```tsx
Contact details
```
### Customize the Header
To customize the header, use `Fieldset.Header`.
```tsx
Contact details
Please provide your contact details below.
```
### Customize the Content
To customize the content, use `Fieldset.Content`.
```tsx
```
## Props
### Fieldset.Root
| Prop | Default | Type | Description |
| -------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ |
| `as` | - | `As` | The HTML element to render. |
| `asChild` | - | `boolean` | Merges its props onto its immediate child. |
| `css` | - | `CSSObject \| CSSObject[]` | The CSS object. |
| `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. |
| `size` | `"md"` | `"lg" \| "md" \| "sm"` | The size of the component. |
| `variant` | `"plain"` | `"elevated" \| "outline" \| "panel" \| "plain"` | The variant of the component. |
| `contentProps` | - | `FieldsetContentProps` | Props the content component. |
| `errorMessage` | - | `ReactNode` | The fieldset error message to use. |
| `errorMessageProps` | - | `FieldsetErrorMessageProps` | Props the error message component. |
| `headerProps` | - | `FieldsetHeaderProps` | Props the header component. |
| `helperMessage` | - | `ReactNode` | The fieldset helper message to use. |
| `helperMessageProps` | - | `FieldsetHelperMessageProps` | Props the helper message component. |
| `invalid` | `false` | `boolean` | If `true`, the field will be invalid. |
| `legend` | - | `ReactNode` | The fieldset legend to use. |
| `legendProps` | - | `FieldsetLegendProps` | Props the legend component. |
| `readOnly` | `false` | `boolean` | If `true`, the field will be readonly. |
| `required` | `false` | `boolean` | If `true`, the field will be required. |
### Fieldset.Content
| Prop | Default | Type | Description |
| ------------- | ------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ |
| `as` | - | `As` | The HTML element to render. |
| `asChild` | - | `boolean` | Merges its props onto its immediate child. |
| `css` | - | `CSSObject \| CSSObject[]` | The CSS object. |
| `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. |
### Fieldset.ErrorMessage
| Prop | Default | Type | Description |
| ------------- | ------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ |
| `as` | - | `As` | The HTML element to render. |
| `asChild` | - | `boolean` | Merges its props onto its immediate child. |
| `css` | - | `CSSObject \| CSSObject[]` | The CSS object. |
| `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. |
### Fieldset.Header
| Prop | Default | Type | Description |
| ------------- | ------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ |
| `as` | - | `As` | The HTML element to render. |
| `asChild` | - | `boolean` | Merges its props onto its immediate child. |
| `css` | - | `CSSObject \| CSSObject[]` | The CSS object. |
| `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. |
### Fieldset.HelperMessage
| Prop | Default | Type | Description |
| ------------- | ------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ |
| `as` | - | `As` | The HTML element to render. |
| `asChild` | - | `boolean` | Merges its props onto its immediate child. |
| `css` | - | `CSSObject \| CSSObject[]` | The CSS object. |
| `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. |
### Fieldset.Legend
| Prop | Default | Type | Description |
| ------------- | ------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ |
| `as` | - | `As` | The HTML element to render. |
| `asChild` | - | `boolean` | Merges its props onto its immediate child. |
| `css` | - | `CSSObject \| CSSObject[]` | The CSS object. |
| `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. |
## Accessibility
### ARIA Roles and Attributes
| Element | Roles and Attributes | Usage |
| ---------------------------------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| `fieldset.ui-fieldset__root` | `aria-labelledby` | Labels the `fieldset` group by referencing the `id` shared with `Fieldset.Legend`, combined with the `aria-labelledby` prop. |
| `span.ui-fieldset__helper-message` | `aria-describedby` | Sets the `id` of the associated `Fieldset.Legend`. |
| `span.ui-fieldset__error-message` | `aria-live="polite"` | Indicates that it may be updated outside of focus if `invalid` is set. |
## Similar Components
- [Field](https://yamada-ui.com/docs/components/field.md): `Field` is a component used to group form elements with label, helper message, error message, etc.
- [Form](https://yamada-ui.com/docs/components/form.md): `Form` is a component used to group multiple form elements.
- [Bleed](https://yamada-ui.com/docs/components/bleed.md): `Bleed` is a component used to extend elements beyond the boundaries of a container.
- [Box](https://yamada-ui.com/docs/components/box.md): `Box` is the most abstract component on which all other components are built. By default, it renders a `div` element.
- [Center](https://yamada-ui.com/docs/components/center.md): `Center` is a component that aligns the child elements in the center within the component.
- [Container](https://yamada-ui.com/docs/components/container.md): `Container` is a component used as a general division element. By default, it renders the `section` element.
- [Flex](https://yamada-ui.com/docs/components/flex.md): `Flex` is a component that sets `flex` to `Box`. Also, convenient style shorthand is available.
- [Float](https://yamada-ui.com/docs/components/float.md): `Float` is a component used to fix elements to the edges of a container.
## Uses Components & Hooks
- [Form](https://yamada-ui.com/docs/components/form.md): `Form` is a component used to group multiple form elements.
- [Field](https://yamada-ui.com/docs/components/field.md): `Field` is a component used to group form elements with label, helper message, error message, etc.
## Used By Components & Hooks
- [Field](https://yamada-ui.com/docs/components/field.md): `Field` is a component used to group form elements with label, helper message, error message, etc.