Skip to main content
HahlexMillarv0.1.0 Draft
ComponentsDraftWCAG 2.1/2.2 AAZero Gradients@hahlex/millar-ui

ChoiceToggle

High-contrast option switch (e.g., Light/Dark or EN/VI) pairing --accent-soft with --fg-on-accent-soft (7.69:1 AAA across both themes).

Interactive Playground

Live component specimen driven directly by Millar tokens in Light and Dark mode.

Selected value: light

Active option uses --accent-soft + --fg-on-accent-soft (7.69:1 AAA), eliminating the 1.00:1 dark-mode invisible text bug.

LIGHT
@hahlex/millar-ui
import { ChoiceToggle } from "@hahlex/millar-ui";

<ChoiceToggle
  label="Theme"
  value={theme}
  onChange={setTheme}
  options={[{ value: "light", label: "Light" }, { value: "dark", label: "Dark" }]}
/>

Props API

ChoiceToggle component props
PropTypeDefaultDescription
labelstring-Accessible group name (aria-label).
valueT-Active option value.
onChange(next: T) => void-Selection callback.
optionsArray<{ value: T; label: string }>-Discrete mutually exclusive options.

Usage Guidelines & Agent Guardrails

When to use
  • Compact binary or ternary preferences (Theme, Locale, Register, Viewport).
Responsive behavior

Compact inline control with 30px internal buttons inside a 38px bordered tray.

Anti-Hallucination Guardrails (AI & Human)
  • Never style active state with --fg-accent on --accent-soft (1.00:1 invisible in dark mode).

Accessibility & Keyboard Contract

role='group' with aria-labelaria-pressed on each option button
Keyboard interactions
KeyBehavior
Tab + Enter/SpaceSelects the focused option.