# FieldSet (suaveplan-only) _(no submodules)_ - field-set.variants — `fieldSetVariants` and `fieldL… - [field-set.variants](./field-set.variants.md) — `fieldSetVariants` and `fieldLegendVariants` are the cva (class-variance-authority) configurations powering `
… - field-set.variants — `fieldSetVariants` and `fieldL… - [field-set.variants](./field-set.variants.md) — `fieldSetVariants` and `fieldLegendVariants` are the cva (class-variance-authority) configurations powering `
… - field-set.variants — `fieldSetVariants` and `fieldL… - [field-set.variants](./field-set.variants.md) — `fieldSetVariants` and `fieldLegendVariants` are the cva (class-variance-authority) configurations powering `
… - field-set.variants — `fieldSetVariants` and `fieldL… - [field-set.variants](./field-set.variants.md) — `fieldSetVariants` and `fieldLegendVariants` are the cva (class-variance-authority) configurations powering `
… - [field-set.variants](./field-set.variants.md) — `fieldSetVariants` and `fieldLegendVariants` are the cva (class-variance-authority) configurations powering `
… ## Purpose `
` and `` are chassis primitives that wrap related controls (typically Checkbox / RadioGroup / Switch groups) inside the native `
` + `` HTML5 elements. The native `
` attribute propagates to every contained form control automatically, which `` (a `
`) cannot replicate. Pair `` with `
` to provide an accessible grouping heading announced by screen readers when navigating into any contained control. **Suaveplan addition** — shadcn does not ship a `FieldSet` registry item upstream. The chassis adds these primitives because the cross-cutting reconciliation note (#1) flagged the gap: `` is a `
` and cannot carry the native `
` semantics. Documented as suaveplan-only so consumers know the source of truth lives in this package, not upstream shadcn. ## Features - `
` renders the native `
` so `disabled` propagates to every contained control via HTML5 semantics. - `` renders the native `` so screen readers announce the grouping when navigating into any contained control. - `data-invalid="true"` on `
` flips descendant `` colour to destructive via the cva `data-[invalid=true]:` selector. - `data-disabled="true"` mirrors the native `disabled` so sibling cva selectors can react. - Refs forwarded on both primitives. - Theme-driven variant overrides via `useThemedVariants("FieldSet" | "FieldLegend")`. - Layout uses `flex flex-col gap-3` (NOT `space-y-*` per shadcn skill rule). ## Usage: Basic Example ```tsx import { FieldSet, FieldLegend, Checkbox } from "@suaveplan/react-ui"; export function PermissionsFieldSet() { return (
Permissions
); } ``` ## Usage: Advanced Example ```tsx import { FieldSet, FieldLegend, RadioGroup, RadioGroupItem, } from "@suaveplan/react-ui"; import { useState } from "react"; export function NotificationFrequency() { const [enabled, setEnabled] = useState(true); const [freq, setFreq] = useState("daily"); // Disabling the entire fieldset propagates `disabled` to every // contained via HTML5 fieldset semantics. return (
Notification frequency
); } ``` ## API Reference ### `
` `forwardRef` — renders the native `
`. #### `FieldSetProps` Inherits every prop from `FieldsetHTMLAttributes`. Adds: | Prop | Type | Default | Description | |---|---|---|---| | `invalid` | `boolean` | `false` | Drives `data-invalid="true"` on the container so descendant `` flips to destructive colour. | The native `disabled` attribute is forwarded as-is and additionally drives `data-disabled="true"` for cva selectors. ### `` `forwardRef` — renders the native ``. #### `FieldLegendProps` Inherits every prop from `HTMLAttributes`. Adds: | Prop | Type | Default | Description | |---|---|---|---| | `invalid` | `boolean` | `false` | Drives `data-invalid="true"` on the legend itself so the destructive colour activates without depending on a parent `
`. | #### Cva resolvers `fieldSetVariants` and `fieldLegendVariants` are exported as bare cva resolvers for external composition. ## Implementation Notes - This is a suaveplan-only addition — shadcn does not ship a `field-set` registry item upstream. The chassis adds it because `` (a `
`) cannot carry the native `
` semantics, and the cross-cutting reconciliation note (#1) flagged the gap. - The native `
` attribute propagates `disabled` to every contained form control automatically. The chassis preserves this semantic by rendering the actual HTML5 element rather than wrapping in a `
`. - The `` `invalid` prop is exposed independently of `
` so consumers can render a legend in error state outside a fieldset (e.g. a custom layout that uses the chassis legend styling without the fieldset wrapper). - Per the shadcn skill rule, the cva NEVER uses `space-y-*` — `gap-3` flows the same in RTL. - Refs target the native `
` / `` so consumers can measure or scroll-into-view programmatically.