Toggle represents one independent button state that remains pressed or not pressed.
Overview and decision boundary
Use Toggle for one independent button state that remains pressed or not pressed, such as following, pinning, muting, or showing an optional layer.
Do not use Toggle for immediate settings, form selection, disclosure, grouped selection, or a momentary action.
1import{Bell,Save}from"@nerio-ui/adapters/icons";2import{Toggle}from"@nerio-ui/ui/client";34<Toggleicon={Bell}aria-label="Follow updates"defaultPressed/>5<Toggleicon={Save}aria-label="Save article for later"variant="outline"/>
Installation and imports
Install the editable registry source, or use the matching package entrypoint when the product keeps Nerio as a workspace dependency.
Restrained default for dense or repeated controls.
outline
Adds a stable boundary around the independent state.
sm / md / lg
Shared action heights for icon-only and visible-label content.
Anatomy
Slot
Purpose
toggle
Native Base UI toggle button and public pressed-state owner.
toggle-icon
Optional leading Nerio icon for visible-label content.
toggle-label
Visible label that remains semantically stable while state changes.
States
State
Behavior
Unpressed
aria-pressed="false"; data-pressed is absent.
Pressed
aria-pressed="true"; data-pressed adds a secondary fill and primary foreground while preserving the variant border.
Hover / active
Transient interaction remains distinct from the retained pressed state.
Focus-visible
Shared focus ring remains visible in both pressed states.
Disabled
Activation is blocked while pressed or unpressed presentation remains visible.
Motion
Hover and press reuse shared CSS-first interaction motion.
The retained pressed state never depends on animation.
Reduced motion removes nonessential duration and scale.
Accessibility
Uses the Base UI Toggle primitive and renders a native type=button by default.
Expose the persistent state through pressed, defaultPressed, onPressedChange, aria-pressed, and data-pressed.
Use a stable accessible name while the pressed state changes; do not alternate labels such as Mute and Unmute when aria-pressed is present.
Icon-only usage requires aria-label at the TypeScript level; visible-label usage derives its name from children unless an explicit ARIA name is supplied.
Enter, Space, pointer, and touch activation toggle exactly one state while focus remains on the control.
Disabled Toggle prevents state changes and preserves a visible pressed or unpressed state.
Use Toggle for an independent retained button state, Button for momentary actions, Switch for immediate settings, and Checkbox for selection.
ButtonGroup does not add grouped selection; use a future ToggleGroup for exclusive or multiple grouped values.
Pressed state uses a secondary surface with primary foreground while preserving the variant border; forced-colors mode adds a system highlight boundary, and the state does not depend on motion.
Review the shared responsibility and evidence boundaries in the Accessibility foundation alongside this component-specific contract. Use the Spacing & layout foundation for shared density, wrapping, overflow, reflow, and component-versus-product ownership guidance. The Color foundation, Typography foundation, and Localization foundation define the shared visual-role, text-resilience, direction, and locale boundaries used by component examples.
API
Prop
Purpose
pressed / defaultPressed / onPressedChange
Controlled and uncontrolled state with Nerio event details and cancellation.
icon / aria-label
Icon-only mode with a required stable accessible name.
children / leadingIcon
Visible-label mode with an optional leading Nerio icon.
variant
Selects "ghost" or "outline"; ghost is the default.
size
Selects "sm", "md", or "lg"; md is the default.
value
Stable identifier reserved for future direct ToggleGroup composition.