Switch
Accessible on/off toggle with role="switch" and keyboard support
Same BEM classes and behavior as Astro, Svelte, and React.
Add this component
Run the command below in your project directory. When prompted, select the component(s) you want. The CLI will copy the CSS and component files.
Choose your package manager — click a tab to select, then copy the command.
Live examples
Usage
Usage
Full example for each framework (Astro, Vanilla, Svelte, Vue, React). Switch framework via View as or by clicking a Usage tab—both stay in sync.
Astro Vanilla Svelte Vue React ---
import Switch from '../components/astro/Switch.astro';
---
<Switch label="Enable notifications" client:load />
<!-- Rizzo CSS. Toggle state via JS (aria-pressed, class switch--pressed). -->
<label class="switch">
<input type="checkbox" class="switch__input" />
<span class="switch__track"></span>
</label>
<script>
import { Switch } from '$lib/rizzo';
let checked = $state(false);
</script>
<Switch label="Enable notifications" bind:checked />
<script setup>
import { ref } from 'vue';
import Switch from '@/components/rizzo/Switch.vue';
</script>
<template>
<Switch
v-model:checked="checked"
label="Enable notifications"
/>
</template>
import { useState } from 'react';
import { Switch } from './components/react';
const [checked, setChecked] = useState(false);
<Switch
label="Enable notifications"
checked={checked}
onCheckedChange={setChecked}
/>
Other frameworks: Astro · Vanilla · Svelte · React