fin1te/dsv1.0.0
  1. ds
  2. Components
  3. Segmented control

Segmented control

Pick one of a few options. Filters and modes.

fin1te

Code
<div class="seg" role="group" aria-label="Show commits from">
  <button aria-pressed="true">All</button>
  <button aria-pressed="false">Work</button>
  <button aria-pressed="false">Personal</button>
</div>

Inline and recessed. The stats and work pages use it to filter what the page shows.

topo, in panels

Code
<div class="seg fill" role="radiogroup" aria-label="Link style" style="max-width:18rem">
  <button role="radio" aria-checked="true">data</button>
  <button role="radio" aria-checked="false">control</button>
  <button role="radio" aria-checked="false">fallback</button>
  <button role="radio" aria-checked="false">stream</button>
</div>

API

ClassOnWhat it does
.segdivThe track. Buttons inside are the options.
.fill.segEqual-width columns, tighter, on --bg.
.sm.segCompact buttons.
aria-pressed / aria-checked / aria-selected / .onbuttonThe selected option.

Accessibility

  • Filters that change what is shown: a role="group" of toggle buttons with aria-pressed.
  • A single value (like a form field): role="radiogroup" and role="radio" with aria-checked, arrow keys to move.