- Home
- Primitives
- Switch
- Examples
Switch
Basic switch example demonstrating core behavior.
Examples
import * as Switch from "@solidiom/switch"
;<Switch.Root>Switch content</Switch.Root>Enable notifications
View source
export function SwitchExample(props: SwitchExampleProps) {
const copy = () => COPY[props.locale]
const [on, setOn] = createSignal(true)
return (
<div ref={(el) => el.setAttribute("data-hydrated", "true")} class="switch-example">
<Switch.Root checked={on} onCheckedChange={setOn} aria-label={copy().label}>
<Switch.Thumb />
</Switch.Root>
<span class="switch-example__label">{copy().label}</span>
</div>
)
}