Basic Usage
Controlled State
With Label
Multiple Toggles
With Tooltip
Disabled State
Props Reference
Whether the toggle button is currently pressed (controlled)
Whether the toggle button is initially pressed (uncontrolled)
Callback fired when the pressed state changes. Receives the new pressed state as a boolean.
A unique string that identifies the toggle when used inside a toggle group
Whether the component should ignore user interaction
Additional CSS classes for styling
Visual States
The toggle has distinct visual states:- Default: Secondary color with hover effect
- Pressed: Darker background and text color
- Hover: Light background highlight
- Active: Slightly darker than hover
- Disabled: Reduced opacity with not-allowed cursor
Styling
From source code atreflex_ui/components/base/toggle.py:11-14:
- Size: 8 units (2rem) square
- Border radius: Small rounded corners
- Colors: Secondary scale with contrast for pressed state
- Transitions: Smooth color changes
- Focus: Visible focus ring on keyboard navigation
Toggle Groups
For multiple related toggles, use the Toggle Group component which manages the state of multiple toggles together.Implementation Details
From source code atreflex_ui/components/base/toggle.py:28-62:
- Built on accessible button primitives
- Supports both controlled and uncontrolled modes
- Automatic keyboard navigation (Space/Enter)
- ARIA attributes for accessibility
- Can be used standalone or within toggle groups