Segmented control

One control, a few exclusive choices. Kobalte's SegmentedControl builds it from a hidden radio per item plus an indicator it positions inline.

alpha The class names and states here are stable. The look is not: these styles can change in a minor release, without a major version bump.

ClassDoes what
segmentedThe track holding the items
segmented-itemOne choice. Checked state comes from its radio, data-checked, or segmented-item-active
segmented-indicatorThe sliding highlight. Leave it out and the checked item paints its own

Basic

<div class="segmented">
  <label class="segmented-item"><input type="radio" name="view" checked /> List</label>
  <label class="segmented-item"><input type="radio" name="view" /> Board</label>
  <label class="segmented-item"><input type="radio" name="view" /> Calendar</label>
</div>

None of Kobalte's parts here carry a role, so the classes go on them by hand. The checked state is read three ways: the item's own radio, Kobalte's data-checked, or .segmented-item-active.

Composition

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

A view switch above results

The switch sits at the end of the row that holds the result count.

Same markup in both builds
<div class="flex" style="justify-content: space-between; align-items: center; flex-wrap: wrap">
  <span class="text-secondary">24 items</span>
  <div class="segmented" role="radiogroup" aria-label="View">
    <label class="segmented-item"><input type="radio" name="cview" checked /> Grid</label>
    <label class="segmented-item"><input type="radio" name="cview" /> List</label>
  </div>
</div>