MiHCM
primitives/@mihcm/ui·v0.21.0·stable

Toggle

Pressable toggle between on/off states. Also exports ToggleGroup for single/multi-select groups.

Use cases

  • Toolbar formatting (variant="default") — bold, italic, underline in a text editor.
  • View switchers — grid vs list layout toggle.
  • Feature flags in a settings panel — enable/disable a capability.
  • Multi-select groups (ToggleGroup type="multiple") — pick multiple text formats at once.
  • Single-select groups (ToggleGroup type="single") — alignment, sort direction.

When NOT to use

  • Binary on/off with a track visual — use Switch.
  • Selecting from a long list — use Select or Tabs.
  • Navigation between pages — use Tabs or a sidebar.

Variants

VariantUse when
defaultToolbar buttons with a subtle pressed background.
outlineStandalone toggle where the border provides affordance.

Composition

  • Pair icon + text for clarity. Icon-only toggles need an aria-label.
  • ToggleGroup with type="single" enforces mutual exclusion (like radio buttons but visually as buttons).
  • ToggleGroup with type="multiple" allows any combination (like checkboxes but visually as buttons).
  • disabled on an individual item prevents toggling without affecting siblings.
  • Switch — binary toggle with track visual.
  • Tabs — tabbed content switching.
  • RadioGroup — single selection in a form context.