Skip to content
navius

Toggle

A two-state button that can be either on or off.

Features

  • Full keyboard navigation.
  • Can be controlled (@bind-Pressed) or uncontrolled (DefaultPressed).
  • aria-pressed reflects the on/off state.
  • Renders a native button, so it is focusable and form-aware by default.

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 part and assemble it.

API Reference

The toggle button. Renders a button.

Prop Type Default
Pressed bool false
PressedChanged EventCallback<bool> -
DefaultPressed bool false
Disabled bool false
ChildContent RenderFragment? -
Data attribute Values
[data-pressed] Present when the toggle is pressed (on)
[data-disabled] Present when disabled

Accessibility

Implements the role and keyboard behavior of the button WAI-ARIA APG pattern. Covered by the browser test suite and an axe-core WCAG gate in CI.

Key Description
Space Activates the toggle, flipping its state.
Enter Activates the toggle, flipping its state.