Skip to content
navius

Toggle Group

A set of two-state buttons that can be toggled on or off.

Features

  • Single (default) or multiple (Multiple="true") pressed values.
  • Can be controlled (@bind-Value) or uncontrolled (DefaultValue).
  • Roving tabindex: the group is a single Tab stop and arrow keys move focus between items.
  • Horizontal or vertical orientation drives the arrow-key axis.
  • Full keyboard navigation with optional wrapping (Loop).
  • RTL aware: horizontal arrow semantics swap under Dir="rtl".

Installation

Reference the Navius.Primitives package for the headless primitive, or vendor a styled version with the CLI: navius add copies the styled zits/ui component plus the brain files it depends on.

Anatomy

Import the parts and assemble them.

API Reference

Contains all the parts of a toggle group. Renders a div with role=group.

Prop Type Default
Multiple bool false
Value IReadOnlyList<string>? -
ValueChanged EventCallback<IReadOnlyList<string>> -
DefaultValue IReadOnlyList<string>? -
Disabled bool false
Orientation string "horizontal"
RovingFocus bool true
Loop bool true
Dir string? -
ChildContent RenderFragment? -
Attributes IDictionary<string, object>? -
Data attribute Values
[data-orientation] "horizontal" | "vertical"
[data-multiple] Present in multiple-selection mode
[data-disabled] Present when disabled

An individual two-state toggle button within the group. Renders a button.

Prop Type Default
Value string ""
Disabled bool false
ChildContent RenderFragment? -
Attributes IDictionary<string, object>? -
Data attribute Values
[data-pressed] Present when the item is pressed (on)
[data-disabled] Present when disabled

Accessibility

Uses roving tabindex to manage focus, implementing the roles and keyboard map of the toolbar WAI-ARIA APG pattern. Behavior is covered by the browser test suite and an axe-core WCAG gate in CI.

Key Description
Tab Moves focus into and out of the group (a single Tab stop).
Space Toggles the focused item on or off.
Enter Toggles the focused item on or off.
ArrowDown Moves focus to the next item (vertical orientation).
ArrowUp Moves focus to the previous item (vertical orientation).
ArrowRight Moves focus to the next item (horizontal orientation).
ArrowLeft Moves focus to the previous item (horizontal orientation).
Home Moves focus to the first item.
End Moves focus to the last item.