Fieldset

Groups related controls behind a border, with the legend notched into it.

ClassDoes what
fieldsetBordered group with padding and a bottom margin
fieldset-legendLegend, pulled into the border

Basic

<fieldset class="fieldset">
  <legend class="fieldset-legend">Shipping</legend>
  <label class="label">
    Address
    <input type="text" class="input" />
  </label>
  <label class="label">
    City
    <input type="text" class="input" />
  </label>
</fieldset>

Composition

Common ways to put this together with other components. The general rules are on Composition.

Grouping filters

One group of filters: a single choice and some that combine, named once by the legend.

Same markup in both builds
<form>
  <label class="label">
    <p>Search</p>
    <input class="input" type="search" />
  </label>
  <fieldset class="fieldset">
    <legend class="fieldset-legend">Filter</legend>
    <div class="flex" style="flex-wrap: wrap; align-items: center">
      <div class="segmented" role="radiogroup" aria-label="Format" style="margin-bottom: 1rem">
        <label class="segmented-item"><input type="radio" name="cfmt" checked /> Any</label>
        <label class="segmented-item"><input type="radio" name="cfmt" /> Print</label>
        <label class="segmented-item"><input type="radio" name="cfmt" /> Digital</label>
      </div>
      <label class="label"><input type="checkbox" class="checkbox" /> Free</label>
      <label class="label"><input type="checkbox" class="checkbox" checked /> In stock</label>
    </div>
  </fieldset>
</form>

A filter with a range

A range in a filter group, with the current value in the label text.

Same markup in both builds
<fieldset class="fieldset">
  <legend class="fieldset-legend">Filter</legend>
  <label class="label">
    <p class="flex" style="justify-content: space-between"><span>Distance</span><span class="text-secondary">5 miles</span></p>
    <input type="range" class="range" min="1" max="20" value="5" style="--range-fill: 21%" />
  </label>
  <label class="label"><input type="checkbox" class="checkbox" /> Open now</label>
</fieldset>

Disabling a group

Disabling the fieldset disables, and greys, everything inside it.

Same markup in both builds
<form class="card">
  <label class="label">
    <input type="checkbox" class="checkbox" />
    Ship to a different address
  </label>
  <fieldset class="fieldset" disabled>
    <legend class="fieldset-legend">Shipping address</legend>
    <label class="label"><p>Street</p><input class="input" /></label>
    <label class="label"><p>City</p><input class="input" /></label>
  </fieldset>
</form>