Component
Toggle
Render controlled or uncontrolled switches with role=switch semantics and token-backed motion.
Interactive preview
Usage
Import the component entry and start with its smallest complete example.
Import
import { Toggle } from "@chitrank2050/monoline-ui/toggle"Basic usage
<Toggle
checked={enabled}
onCheckedChange={setEnabled}
aria-label="Enable notifications"
/>Usage guidance
Choose the component for its interaction model and semantics before customizing its appearance.
Toggle handles one binary setting that takes effect immediately, whether its state is controlled or internal.
The value is submitted with a form, belongs to a mutually exclusive group, or is an action rather than persistent state.
Toggle uses a button with role switch and aria-checked. Its accessible label should describe the setting, not the action that will happen next.
This component needs browser JavaScript for state or browser APIs.
API reference
Props, slots, and callbacks available on this component.
Design tokens
Theme variables this component reads for color, spacing, and motion.
Implementation
The source used by the example above, including any state it needs.
import { Toggle } from "@chitrank2050/monoline-ui/toggle"
export function SettingsToggle() {
return (
<Toggle
defaultChecked
aria-label="Enable dark mode"
/>
)
}Related documentation
Compare related components or review the package and theme setup.