Switch
A control that allows the user to toggle between on and off states.
Installation
import { Switch } from "@sourceful-energy/ui"Usage
Examples
Default Checked
Disabled
With Description
Optimize charging based on grid conditions.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| checked | boolean | false | The controlled checked state. |
| defaultChecked | boolean | false | The default checked state when uncontrolled. |
| onCheckedChange | (checked: boolean) => void | - | Callback when the checked state changes. |
| disabled | boolean | false | Whether the switch is disabled. |
| id | string | - | The ID for associating with a label. |
Accessibility
- Uses native switch role via Radix UI
- Keyboard accessible (Space to toggle)
- Always pair with a Label for screen readers
- Visible focus indicator