Fieldset

A native fieldset and legend that give a group of related form fields one name. Use it for an address, a set of checkboxes or a block of fields that can be disabled together.

  • vig-fieldset
Import
import { Fieldset } from '@vigdx/ui/fieldset';

Basic

legend names the group; project the fields.

Shipping address

Checkbox group, disabled and collapsible

Checkboxes have no group component of their own: wrap them in a fieldset. disabled disables the native fieldset and with it every control inside. collapsible puts a disclosure button in the legend; [(collapsed)] holds the state.

Radio buttons and checkboxes

vig-radio-group already renders a fieldset with its label as the legend, plus the group's required and invalid states: do not wrap a single radio group in a vig-fieldset just to name it. Use vig-fieldset for checkbox lists and for groups that mix several fields.

disabled is the native fieldset attribute: the browser disables the native controls inside and leaves them out of form submission, and the kit's controls follow it too (their own widgets such as rating and knob sliders, and their disabled look), also through nested fieldsets. The forms model is not changed: to disable fields in Signal Forms or Reactive Forms, disable them there.

The group's name is the legend input rather than the kit's usual heading: it renders the native <legend>, which names the group but is not a heading.

Styling hooks

Internal elements carry a stable data-part and the component's data-scope; both are public API, so removing one is a breaking change. Select a part by both, e.g. [data-scope="fieldset"][data-part="group"] { … }: the pair stays within this component when kit components nest, and also reaches parts in overlay panels, which render outside the host. State is exposed through aria-* and, where listed, a data-state; literal values are checked by the API gate, values computed from the component's state follow its documented types. Other data-* attributes listed below (such as data-opening while an overlay animates) are API too. See Customizing.

Scope: [data-scope="fieldset"]

Fieldset styling hooks
Part Element data-state
group The native <fieldset> . open, closed
legend The <legend> . —
trigger The disclosure button in the legend of a collapsible fieldset. open, closed
indicator The chevron of the trigger. —
content The collapsible part ( hidden="until-found" while collapsed); data-state only when collapsible. open, closed
body The column of projected fields. —

Accessibility

  • Native semantics: the <legend> names the group, and screen readers announce it when focus enters the group.
  • The collapse button sits inside the legend, so the legend keeps naming the group; it stays usable while the fieldset is disabled. Collapsed fields stay in the DOM as hidden="until-found": they keep their values and are submitted, and find-in-page reveals them.

API

Fieldset

vig-fieldset component

A native <fieldset> with its <legend>: groups related fields under one name that screen readers announce on entering the group (an address, a set of checkboxes). disabled disables the native fieldset, which disables every native control inside it, the kit's fields included.

Example :
<vig-fieldset legend="Shipping address">
  <vig-input label="Street" … />
  <vig-input label="City" … />
</vig-fieldset>

collapsible puts a disclosure button (aria-expanded, aria-controls) in the legend, which keeps naming the group; the fields of a collapsed fieldset stay in the DOM as hidden="until-found" (still submitted, and find-in-page expands it). The legend's button stays usable while the fieldset is disabled, as the HTML spec has it.

Fieldset props
Name Type Default Description
collapsed model booleanfalse

Whether the fields are collapsed; two-way bindable. Ignored unless collapsible.

collapsiblebooleanfalse

Puts a button in the legend that collapses and expands the fields.

disabledbooleanfalse

Disables the native fieldset and with it every native control inside.

legend required string—

The group's name, rendered in the <legend>.

Are you sure?