Fieldset
Groups related form fields, propagates disabled state to nested fields, and links group labels and descriptions.
Groups related form fields under one accessible group container, propagates disabled down through nested groups, and automatically links its legend and description. The examples on this page use the Shadcn Rhea style preset.
Preview
Section titled “Preview”<proto-ui-shadcn-style-scope>
<proto-ui-shadcn-fieldset-root>
<proto-ui-shadcn-fieldset-legend>
Address Information
</proto-ui-shadcn-fieldset-legend>
<proto-ui-shadcn-fieldset-description>
We need your address to deliver your order.
</proto-ui-shadcn-fieldset-description>
<div class="grid gap-4">
<proto-ui-shadcn-field-root>
<proto-ui-shadcn-field-label>
Street Address
</proto-ui-shadcn-field-label>
<proto-ui-shadcn-field-control></proto-ui-shadcn-field-control>
<proto-ui-shadcn-field-error></proto-ui-shadcn-field-error>
</proto-ui-shadcn-field-root>
<div class="grid grid-cols-2 gap-4">
<proto-ui-shadcn-field-root>
<proto-ui-shadcn-field-label>
City
</proto-ui-shadcn-field-label>
<proto-ui-shadcn-field-control></proto-ui-shadcn-field-control>
</proto-ui-shadcn-field-root>
<proto-ui-shadcn-field-root>
<proto-ui-shadcn-field-label>
Postal Code
</proto-ui-shadcn-field-label>
<proto-ui-shadcn-field-control></proto-ui-shadcn-field-control>
</proto-ui-shadcn-field-root>
</div>
</div>
</proto-ui-shadcn-fieldset-root>
</proto-ui-shadcn-style-scope>Installation
Section titled “Installation”Available starting in 0.3.0-rc.1 and later releases.
import { FieldsetRoot, FieldsetLegend, FieldsetDescription } from '@/components/shadcn/fieldset';import { FieldRoot, FieldLabel, FieldControl } from '@/components/shadcn/field';
export function Example() { return ( <FieldsetRoot> <FieldsetLegend>Address Information</FieldsetLegend> <FieldsetDescription>We need your address to deliver your order.</FieldsetDescription> <FieldRoot required> <FieldLabel>Street Address</FieldLabel> <FieldControl placeholder="123 Main St" /> </FieldRoot> </FieldsetRoot> );}Anatomy
Section titled “Anatomy”Compose Fieldset from Root, Legend, and Description:
- Root: Unboxed vertical flex container (
gap-6onrhea,vega,maia,luma,sera, andnew-york-v4;gap-4onnova,lyra, andmira) declaring thegrouprole and effectivedisabledpolicy. - Legend: Optional medium-weight group title supporting
variant="legend"(default) andvariant="label", automatically linked viaaria-labelledby. - Description: Optional muted help text automatically linked via
aria-describedby.
Both Legend and Description are passive and add no tab stops. Provide at most one Legend and one Description per group (duplicate parts are ignored), and nested groups never borrow each other’s labels or descriptions.
Nested disabled inheritance
Section titled “Nested disabled inheritance”Effective disabled combines a Root’s own disabled prop with any enclosing Fieldset. For outer → middle → inner:
- Disabling
outerdisables all three. - Disabling
middleand then re-enablingouterkeepsmiddleandinnerdisabled. - Re-enabling
middlere-enablesinnerunlessinnerhasdisabled={true}.
Participating Field components inside the group (including any placed inside Legend) inherit the effective disabled state automatically. Form submission and reset belong to Form.
Examples
Section titled “Examples”Label-scale legend and checkbox group
Section titled “Label-scale legend and checkbox group”Pass variant="label" to Legend when pairing a fieldset with compact checkbox lists or option controls.
<proto-ui-shadcn-fieldset-root>
<proto-ui-shadcn-fieldset-legend id="desktop-legend">
Desktop items
</proto-ui-shadcn-fieldset-legend>
<proto-ui-shadcn-fieldset-description>
Select the items you want to show on the desktop.
</proto-ui-shadcn-fieldset-description>
<proto-ui-shadcn-checkbox-group-root id="desktop-group">
<proto-ui-shadcn-checkbox-group-all>
Select all
</proto-ui-shadcn-checkbox-group-all>
<proto-ui-shadcn-checkbox-group-item>
Hard disks
</proto-ui-shadcn-checkbox-group-item>
<proto-ui-shadcn-checkbox-group-item>
External disks
</proto-ui-shadcn-checkbox-group-item>
<proto-ui-shadcn-checkbox-group-item>
Connected servers
</proto-ui-shadcn-checkbox-group-item>
</proto-ui-shadcn-checkbox-group-root>
</proto-ui-shadcn-fieldset-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
setElementProps(document.querySelector('#desktop-legend'), {
variant: 'label',
});
setElementProps(document.querySelector('#desktop-group'), {
defaultValue: ['hard-disks', 'connected-servers'],
ariaLabel: 'Desktop items',
});
</script>Radio group
Section titled “Radio group”Combine RadioGroup with Fieldset to share a group heading, helper text, and accessible naming.
<proto-ui-shadcn-style-scope>
<proto-ui-shadcn-fieldset-root>
<proto-ui-shadcn-fieldset-legend id="plan-legend">
Subscription Plan
</proto-ui-shadcn-fieldset-legend>
<proto-ui-shadcn-fieldset-description>
Yearly and lifetime plans offer significant savings.
</proto-ui-shadcn-fieldset-description>
<proto-ui-shadcn-radio-group-root id="plan-group">
<div class="flex items-center gap-2">
<proto-ui-shadcn-radio-group-item>
<proto-ui-shadcn-radio-group-indicator></proto-ui-shadcn-radio-group-indicator>
</proto-ui-shadcn-radio-group-item>
<proto-ui-shadcn-label-root>
Monthly ($9.99/month)
</proto-ui-shadcn-label-root>
</div>
<div class="flex items-center gap-2">
<proto-ui-shadcn-radio-group-item>
<proto-ui-shadcn-radio-group-indicator></proto-ui-shadcn-radio-group-indicator>
</proto-ui-shadcn-radio-group-item>
<proto-ui-shadcn-label-root>
Yearly ($99.99/year)
</proto-ui-shadcn-label-root>
</div>
<div class="flex items-center gap-2">
<proto-ui-shadcn-radio-group-item>
<proto-ui-shadcn-radio-group-indicator></proto-ui-shadcn-radio-group-indicator>
</proto-ui-shadcn-radio-group-item>
<proto-ui-shadcn-label-root>
Lifetime ($299.99)
</proto-ui-shadcn-label-root>
</div>
</proto-ui-shadcn-radio-group-root>
</proto-ui-shadcn-fieldset-root>
</proto-ui-shadcn-style-scope>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
setElementProps(document.querySelector('#plan-legend'), {
variant: 'label',
});
setElementProps(document.querySelector('#plan-group'), {
defaultValue: 'monthly',
a11yLabel: 'Subscription Plan',
});
</script>Nested disabled inheritance
Section titled “Nested disabled inheritance”Toggle the outer and middle groups independently to inspect cascading disabled propagation and local flag retention.
<div class="grid gap-4">
<div class="flex gap-2">
<proto-ui-shadcn-button id="toggle-outer">
Toggle outer disabled
</proto-ui-shadcn-button>
<proto-ui-shadcn-button id="toggle-middle">
Toggle middle disabled
</proto-ui-shadcn-button>
</div>
<proto-ui-shadcn-fieldset-root id="outer-group">
<proto-ui-shadcn-fieldset-legend>
Workspace Policy (Outer)
</proto-ui-shadcn-fieldset-legend>
<proto-ui-shadcn-fieldset-description>
Disabling an outer group cascades into every nested group and
field.
</proto-ui-shadcn-fieldset-description>
<proto-ui-shadcn-fieldset-root id="middle-group">
<proto-ui-shadcn-fieldset-legend>
Billing Department (Middle)
</proto-ui-shadcn-fieldset-legend>
<proto-ui-shadcn-fieldset-root id="inner-group">
<proto-ui-shadcn-fieldset-legend>
Invoice Overrides (Inner)
</proto-ui-shadcn-fieldset-legend>
<proto-ui-shadcn-field-root>
<proto-ui-shadcn-field-label>
Purchase order
</proto-ui-shadcn-field-label>
<proto-ui-shadcn-field-control></proto-ui-shadcn-field-control>
</proto-ui-shadcn-field-root>
</proto-ui-shadcn-fieldset-root>
</proto-ui-shadcn-fieldset-root>
</proto-ui-shadcn-fieldset-root>
</div>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
let outer = false;
let middle = false;
document
.querySelector('#toggle-outer')
?.addEventListener('click', () => {
outer = !outer;
setElementProps(document.querySelector('#outer-group'), {
disabled: outer,
});
});
document
.querySelector('#toggle-middle')
?.addEventListener('click', () => {
middle = !middle;
setElementProps(document.querySelector('#middle-group'), {
disabled: middle,
});
});
</script>Accessible label and multiple sections
Section titled “Accessible label and multiple sections”Provide ariaLabel on Root when omitting a visible Legend, and pair multiple fieldsets with Separator.
<div class="grid gap-6">
<proto-ui-shadcn-fieldset-root id="delivery-group">
<proto-ui-shadcn-fieldset-description>
Named via ariaLabel without rendering a visible Legend.
</proto-ui-shadcn-fieldset-description>
<proto-ui-shadcn-field-root>
<proto-ui-shadcn-field-label>
Delivery notes
</proto-ui-shadcn-field-label>
<proto-ui-shadcn-field-control></proto-ui-shadcn-field-control>
</proto-ui-shadcn-field-root>
</proto-ui-shadcn-fieldset-root>
<proto-ui-shadcn-separator-root></proto-ui-shadcn-separator-root>
<proto-ui-shadcn-fieldset-root>
<proto-ui-shadcn-fieldset-legend>
Billing Contact
</proto-ui-shadcn-fieldset-legend>
<proto-ui-shadcn-fieldset-description>
Receipts and tax invoices are sent to this recipient.
</proto-ui-shadcn-fieldset-description>
<proto-ui-shadcn-field-root>
<proto-ui-shadcn-field-label>
Contact email
</proto-ui-shadcn-field-label>
<proto-ui-shadcn-field-control></proto-ui-shadcn-field-control>
</proto-ui-shadcn-field-root>
</proto-ui-shadcn-fieldset-root>
</div>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
setElementProps(document.querySelector('#delivery-group'), {
ariaLabel: 'Delivery preferences',
});
</script>| Prop | Type | Default |
|---|---|---|
disabled | boolean | false |
ariaLabel | string | '' |
styleProfile | 'nova' 'rhea' 'vega' 'maia' 'lyra' 'mira' 'luma' 'sera' 'new-york-v4' | 'nova' |
Legend
Section titled “Legend”| Prop | Type | Default |
|---|---|---|
variant | 'legend' 'label' | 'legend' |
styleProfile | 'nova' 'rhea' 'vega' 'maia' 'lyra' 'mira' 'luma' 'sera' 'new-york-v4' | 'nova' |
Description
Section titled “Description”| Prop | Type | Default |
|---|---|---|
styleProfile | 'nova' 'rhea' 'vega' 'maia' 'lyra' 'mira' 'luma' 'sera' 'new-york-v4' | 'nova' |
All three parts expose read-only effective disabled state (ExposeState<boolean>) controlled via Root’s disabled prop.