Browse docs

Segmented control

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

stableSince 0.2.0

On this page
  1. Semantic HTML
  2. Class contract
ExampleScroll inside to see moreOpen in a new page

The .pl-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="pl-c-segmented" role="radiogroup" aria-label="View mode">
  <label class="pl-c-segmented__item">
    <input type="radio" name="view" checked />
    <span>List</span>
  </label>
  <label class="pl-c-segmented__item">
    <input type="radio" name="view" />
    <span>Grid</span>
  </label>
</div>

Class contract

Selector Role
.pl-c-segmented Container (pill, inline-flex).
.pl-c-segmented__item A label wrapping a radio input.
:has(input:checked) Active segment (accent fill).

Search Porchlight