Toggle Group
Group of toggle buttons (single or multiple selection)
Same BEM classes and behavior as Astro, Svelte, and Vue.
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 ToggleGroup from '../components/astro/ToggleGroup.astro';
---
<ToggleGroup type="single" aria-label="Format">
<button type="button" class="btn" aria-pressed="false">Left</button>
<button type="button" class="btn" aria-pressed="true">Center</button>
<button type="button" class="btn" aria-pressed="false">Right</button>
</ToggleGroup>
<!-- Rizzo CSS. No script needed for static. -->
<div class="toggle-group" role="group">...</div>
<script>
import { ToggleGroup, Toggle } from '$lib/rizzo';
</script>
<ToggleGroup type="single" aria-label="Format">
<Toggle pressed={false}>Left</Toggle>
<Toggle pressed={true}>Center</Toggle>
<Toggle pressed={false}>Right</Toggle>
</ToggleGroup>
<script setup>
import ToggleGroup from '@/components/rizzo/ToggleGroup.vue';
import Toggle from '@/components/rizzo/Toggle.vue';
</script>
<template>
<ToggleGroup type="single" aria-label="Format">
<Toggle :pressed="false">Left</Toggle>
<Toggle :pressed="true">Center</Toggle>
<Toggle :pressed="false">Right</Toggle>
</ToggleGroup>
</template>
import { ToggleGroup, Toggle } from './components/react';
<ToggleGroup type="single" aria-label="Format">
<Toggle pressed={false}>Left</Toggle>
<Toggle pressed={true}>Center</Toggle>
<Toggle pressed={false}>Right</Toggle>
</ToggleGroup>
Other frameworks: Astro · Vanilla · Svelte · Vue