Loading...
Installation
Install the following dependencies:
Copy and paste the following code into your project.
Loading...
Update the import paths to match your project setup.
Composition
Toggle └── ToggleIndicator (optional)
Examples
Default
Loading...
Disabled
Loading...
Sizes
Loading...
Variants
Loading...
With Icon
Loading...
With Tooltip
Loading...
API Reference
Toggle
| Prop | Type | Default | Description |
|---|---|---|---|
id | string | undefined | — | Unique identifier used to connect the component parts. |
disabled | boolean | undefined | false | Disables interaction with the component. |
defaultPressed | boolean | undefined | — | Configures default pressed. |
pressed | boolean | undefined | — | Configures pressed. |
onPressedChange | ((pressed: boolean) => void) | undefined | — | Runs when pressed changes. |
size | "default" | "lg" | "sm" | "default" | - |
variant | "default" | "outline" | "default" | - |
Context, Hooks, and Types
| Export | API |
|---|---|
ToggleContext | Render-prop component that exposes component state and actions. |
useToggle | Creates or accesses the component API. |
useToggleContext | Returns the nearest component API. |
Utilities and Supporting Types
| Export | API |
|---|---|
toggleVariants | Style recipe used to reuse the component variants. |
Angular
React
Solid
Svelte
Vue