← Home v1.3.0

Docs / Components / Segmented control

Segmented control

A segmented control for switching views or options: a row of AceCSS buttons with aria-pressed, in three sizes and a full-width variant. Accessible, dark-mode ready, no JavaScript needed for the styles.

Segmented control

A group of buttons where only one can be chosen at a time, so it reads as a single control. The active segment uses --primary and the others use --secondary. Mark the active one with aria-pressed="true". Use it for switching views, periods or filters. It isn't for actions.

<div class="ace-segmented" role="group" aria-label="Period">
  <button type="button" class="ace-btn ace-btn--secondary" aria-pressed="false">Day</button>
  <button type="button" class="ace-btn ace-btn--primary"   aria-pressed="true">Week</button>
  <button type="button" class="ace-btn ace-btn--secondary" aria-pressed="false">Month</button>
</div>

Sizes: ace-segmented--xs (24px) · --sm (36px, toolbar) · default (40px)
Full width with equal segments: ace-segmented--block

<!-- Vue: swap the variant on the active value -->
:class="['ace-btn', v === modelValue ? 'ace-btn--primary' : 'ace-btn--secondary']"
:aria-pressed="v === modelValue"

Use it

One stylesheet from the CDN, pinned to v1.3.0:

<link rel="stylesheet" href="https://acecss.dev/v1.3.0/ace.min.css"
      integrity="sha384-zHAwOqjifsc0D+iUvzD1a4W0R2g0BOK9AqQJZGakUEp/Tm5IUcP07R9xkY0q/stj" crossorigin="anonymous">

Or from npm:

npm i @acecss/core

import '@acecss/core'

Bundlers, Tailwind, every script in one file and self-hosting: Install.

More components