Component Porchlight CSS

Segmented Control

Compact inline switcher for binary/ternary toggles. CSS-only, native radio inputs.

52 components 51 stable 1 experimental

Command

Search Porchlight

Segmented Control

The .c-segmented is a pill-shaped inline switcher. Active segment gets accent styling via :has(:checked). Built on native radio inputs - keyboard accessible, no JavaScript.

Semantic HTML

<div class="c-segmented" role="radiogroup" aria-label="View mode">
  <label class="c-segmented__item">
    <input type="radio" name="view" checked />
    <span>List</span>
  </label>
  <label class="c-segmented__item">
    <input type="radio" name="view" />
    <span>Grid</span>
  </label>
</div>

Class contract

SelectorRole
.c-segmentedContainer (pill, inline-flex).
.c-segmented__itemA label wrapping a radio input.
:has(input:checked)Active segment (accent fill).