Components
Segmented control
Two or three exclusive views of one thing, as icons in a card, with the selected one in glass.
Usage
Both states
<div role="group" aria-label="How to show the projects" className="aka-card inline-flex items-center gap-0.5 rounded-lg p-0.5">
<button type="button" aria-pressed="true" aria-label="Deck" className="aka-hint-host aka-glass grid h-7 w-7 place-items-center rounded-md text-background">
<Layers aria-hidden className="h-[15px] w-[15px]" />
</button>
<button type="button" aria-pressed="false" aria-label="Grid" className="aka-hint-host grid h-7 w-7 place-items-center rounded-md text-muted-foreground transition-colors hover:text-foreground">
<LayoutGrid aria-hidden className="h-[15px] w-[15px]" />
</button>
</div>Shown twice, once in each state, because a single frame cannot show both a ramp end and the off dress. Each option is led from its own end of the glass ramp, the second with aka-glass-rose, so switching changes the colour of the chip and not only its position. ViewToggle on /demo is the working instance; the carousel's two buttons use the same frame.
Best practices
When to use
- Two or three mutually exclusive layouts of the same thing, where a picture of the layout says it faster than its name.
- Words, or a radio group, when the options are not pictures.
Behaviour
- The selected state is the deck's own glass. Law 02 spends the accent once per screen and the test is subject, not count: the deck's pill and the control that selects the deck are one subject.
- The ink on the selected option is text-background, which clears the glass from either end of the ramp.
Accessibility
- role="group" with an aria-label on the frame, aria-pressed on each button, and an aria-label per button.
- A hint per button, since an icon alone is not a label for a sighted reader either.