Duostrap Fieldset
A Duostrap form grouping container with semantic legend, description, and cascading disabled state.
Duostrap Fieldset groups related form fields with a semantic heading, helper text, and cascading disabled state using Duostrap’s borderless block container and bottom-bordered legend styling.
Preview
Section titled “Preview” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<proto-ui-duostrap-fieldset-root>
<proto-ui-duostrap-fieldset-legend>
Address Information
</proto-ui-duostrap-fieldset-legend>
<proto-ui-duostrap-fieldset-description>
We need your address to deliver your order.
</proto-ui-duostrap-fieldset-description>
<div class="grid gap-4">
<proto-ui-duostrap-field-root>
<proto-ui-duostrap-field-label>
Street Address
</proto-ui-duostrap-field-label>
<proto-ui-duostrap-field-control></proto-ui-duostrap-field-control>
<proto-ui-duostrap-field-error></proto-ui-duostrap-field-error>
</proto-ui-duostrap-field-root>
<div class="grid grid-cols-2 gap-4">
<proto-ui-duostrap-field-root>
<proto-ui-duostrap-field-label>
City
</proto-ui-duostrap-field-label>
<proto-ui-duostrap-field-control></proto-ui-duostrap-field-control>
</proto-ui-duostrap-field-root>
<proto-ui-duostrap-field-root>
<proto-ui-duostrap-field-label>
Postal Code
</proto-ui-duostrap-field-label>
<proto-ui-duostrap-field-control></proto-ui-duostrap-field-control>
</proto-ui-duostrap-field-root>
</div>
</div>
</proto-ui-duostrap-fieldset-root>Installation
Section titled “Installation”Available starting in 0.3.0-rc.1 and later releases.
import { FieldsetRoot, FieldsetLegend, FieldsetDescription,} from '@/components/duostrap/fieldset';import { FieldRoot, FieldLabel, FieldControl } from '@/components/duostrap/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> );}Compose Root with an optional Legend and Description:
- Cascading disabled state: A group is disabled whenever its own
disabledprop or any enclosingFieldsetis disabled. Re-enabling an outer group preserves any localdisabledflags on inner groups. ContainedFieldcontrols—including fields insideLegend—automatically inherit the disabled state. - Automatic ARIA wiring:
Rootexposes thegrouprole and automatically links its scopedLegendandDescriptionwithout manual DOM IDs. Include at most oneLegendand oneDescriptionper group; duplicate targets ignore invalid configuration and stay inactive. - Visual styling:
Rootrenders as a borderless block group;Legenduses a full-width21pxheading (40pxline height,20pxbottom margin) with a theme-awareborder-borderbottom rule;Descriptionrenders14px(20pxline height) muted, wrapping helper text.
Examples
Section titled “Examples”Checkbox group
Section titled “Checkbox group” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<proto-ui-duostrap-fieldset-root>
<proto-ui-duostrap-fieldset-legend id="desktop-legend">
Desktop items
</proto-ui-duostrap-fieldset-legend>
<proto-ui-duostrap-fieldset-description>
Select the items you want to show on the desktop.
</proto-ui-duostrap-fieldset-description>
<proto-ui-duostrap-checkbox-group-root id="desktop-group">
<proto-ui-duostrap-checkbox-group-all>
Select all
</proto-ui-duostrap-checkbox-group-all>
<proto-ui-duostrap-checkbox-group-item>
Hard disks
</proto-ui-duostrap-checkbox-group-item>
<proto-ui-duostrap-checkbox-group-item>
External disks
</proto-ui-duostrap-checkbox-group-item>
<proto-ui-duostrap-checkbox-group-item>
Connected servers
</proto-ui-duostrap-checkbox-group-item>
</proto-ui-duostrap-checkbox-group-root>
</proto-ui-duostrap-fieldset-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
setElementProps(document.querySelector('#desktop-group'), {
defaultValue: ['hard-disks', 'connected-servers'],
ariaLabel: 'Desktop items',
});
</script>Nested disabled inheritance
Section titled “Nested disabled inheritance” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<div class="grid gap-4">
<div class="flex gap-2">
<proto-ui-duostrap-button id="toggle-outer">
Toggle outer disabled
</proto-ui-duostrap-button>
<proto-ui-duostrap-button id="toggle-middle">
Toggle middle disabled
</proto-ui-duostrap-button>
</div>
<proto-ui-duostrap-fieldset-root id="outer-group">
<proto-ui-duostrap-fieldset-legend>
Workspace Policy (Outer)
</proto-ui-duostrap-fieldset-legend>
<proto-ui-duostrap-fieldset-description>
Disabling an outer group cascades into every nested group and
field.
</proto-ui-duostrap-fieldset-description>
<proto-ui-duostrap-fieldset-root id="middle-group">
<proto-ui-duostrap-fieldset-legend>
Billing Department (Middle)
</proto-ui-duostrap-fieldset-legend>
<proto-ui-duostrap-fieldset-root id="inner-group">
<proto-ui-duostrap-fieldset-legend>
Invoice Overrides (Inner)
</proto-ui-duostrap-fieldset-legend>
<proto-ui-duostrap-field-root>
<proto-ui-duostrap-field-label>
Purchase order
</proto-ui-duostrap-field-label>
<proto-ui-duostrap-field-control></proto-ui-duostrap-field-control>
</proto-ui-duostrap-field-root>
</proto-ui-duostrap-fieldset-root>
</proto-ui-duostrap-fieldset-root>
</proto-ui-duostrap-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>| Prop | Type | Default |
|---|---|---|
disabled | boolean | false |
ariaLabel | string | '' |
Legend and Description
Section titled “Legend and Description”Legend and Description declare no props of their own; all three parts expose read-only effective disabled state (ExposeState<boolean>).