--- 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 --- ```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 Currently, this section is being updated due to the migration of v2.