Skip to content

Fieldset

How
A native <fieldset class=“sdc-fieldset”> with a <legend> and an optional .sdc-fieldset__desc tied to it with aria-describedby. Fieldset.astro writes it.
When
Whenever two or more controls only make sense together: a set of Choice chips, a pair of date fields, a name split across two inputs.
Where
Inside a form, around the controls it names.

A heading above a group of controls is read as a heading. It is not announced as the group’s name, so someone moving control to control hears “Call me, checkbox” with nothing saying what the question was. A legend is announced with each control in the group, which is the whole point of it.

The legend takes .sdc-display-3, the display face at heading size, so it reads like the heading it replaces while still being a legend element. The default browser border and padding are removed, which is safe: none of the grouping behaviour lives in the border.

src/components/ui/Fieldset.astro.

---
import Fieldset from '../../components/ui/Fieldset.astro';
---
<Fieldset legend="How should people reach you?" desc="Pick as many as you like.">
<div class="sdc-choice-set">…</div>
</Fieldset>
Prop Type Default What it does
legend string required The group’s name
desc string none One line under the legend, tied with aria-describedby
id string from the legend Only needed when desc is set and the legend is not unique
  1. The legend says what the group is asking, not what the page is about.
  2. A screen reader announces the legend with each control.
  3. There is no heading duplicating the legend directly above it.