Toggle Group
Toggle buttons sharing a selection.
Anatomy
A Toggle Group wraps a set of Toggle parts. Import both and nest the toggles inside the group:
<script>
import { Toggle } from '@shardsui/svelte/toggle'
import { ToggleGroup } from '@shardsui/svelte/toggle-group'
</script>
<ToggleGroup>
<Toggle value="bold" />
</ToggleGroup>Give every toggle a value — those strings are what the group's value array holds.
Examples
Multiple
Set the multiple prop to let more than one toggle stay pressed at once.
Inside a toolbar
A group nested in a Toolbar joins the toolbar's arrow-key navigation and its single tab stop. The toolbar's orientation and loopFocus apply instead of the group's, and Home / End no longer move focus. Toolbar.Root / Toolbar.Group also cascade their disabled down to the toggles.
<Toolbar.Root>
<ToggleGroup value={['bold']}>
<Toggle value="bold">Bold</Toggle>
<Toggle value="italic">Italic</Toggle>
</ToggleGroup>
<Toolbar.Separator />
<Toolbar.Button>Clear</Toolbar.Button>
</Toolbar.Root>API reference
Keyboard:
The group is one tab stop: Tab moves into it and out again, arrow keys move between the toggles, and disabled toggles are skipped.