Components / Core
Switch
An on/off setting that applies immediately. Use Checkbox for choices saved with a form.
import { Switch } from "@stylhero/ui";
Example
Code
import { Switch } from "@stylhero/ui";
function SwitchExample() {
return <Switch label="Dark mode" />;
}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
label required |
ReactNode |
- |
Also takes every <input> attribute (id, style, data-*, aria-*, event handlers…), passed to that element. Takes a ref.
Keyboard
| Key | Does |
|---|---|
| Space | Toggles it |
Accessibility
- A native checkbox with
role="switch", announced as on / off.
Generated from src/components/Switch.tsx. Something wrong or missing? Open an issue.