--- title: Fieldset description: "`Fieldset`は、フィールドセット要素に、レジェンド、ヘルパーメッセージ、エラーメッセージなどをグループ化するために使用されるコンポーネントです。" 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 ``` ## 使い方 ```tsx import { Fieldset } from "@yamada-ui/react" ``` ```tsx import { Fieldset } from "@/components/ui" ``` ```tsx import { Fieldset } from "@workspaces/ui" ``` ```tsx ``` ### バリアントを変更する ```tsx {(variant, index) => ( )} ``` ### サイズを変更する ```tsx {(size, index) => ( )} ``` ### ヘルプメッセージを表示する ヘルプメッセージを表示する場合は、`helperMessage`に`ReactNode`を設定します。 ```tsx ``` または、`Fieldset.HelperMessage`を使用してカスタマイズすることも可能です。 ```tsx Please provide your contact details below. ``` ### エラーメッセージを表示する エラーメッセージを表示する場合は、`invalid`を`true`に設定し、`errorMessage`に`ReactNode`を設定します。 ```tsx ``` または、`Fieldset.ErrorMessage`を使用してカスタマイズすることも可能です。 ```tsx Some fields are invalid. Please check them. ``` ### 必須にする 必須にする場合は、`required`を`true`に設定します。 ```tsx ``` ### 無効にする 無効にする場合は、`disabled`を`true`に設定します。 ```tsx ``` ### 読み取り専用にする 読み取り専用にする場合は、`readOnly`を`true`に設定します。 ```tsx ``` ### 無効な入力にする 無効な入力にする場合は、`invalid`を`true`に設定します。 ```tsx ``` ### キャプションをカスタマイズする キャプションをカスタマイズする場合は、`Fieldset.Legend`を使用します。 ```tsx Contact details ``` ### ヘッダーをカスタマイズする ヘッダーをカスタマイズする場合は、`Fieldset.Header`を使用します。 ```tsx Contact details Please provide your contact details below. ``` ### コンテンツをカスタマイズする コンテンツをカスタマイズする場合は、`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. | ## アクセシビリティ 現在、v2の移行に伴い、このセクションは更新中です。