Components
Segmented control
Switches between views of the same content. The chosen segment lifts; there is no underline. Built on the Tabs component, so it works with the keyboard and screen readers.
Views of one list
- 1 Maryam K.
- 2 Arash
- 1 Niloufar R.
- 2 Maryam K.
- 1 Kaveh
- 2 Niloufar R.
A setting with two or three values
Toggle group: the language switch and view choices use it.
Code
Tabs · Segmented control: views of the same content.
import * as Tabs from '#lib/components/ui/tabs/index.js';
<Tabs.Root value="month">
<Tabs.List>
<Tabs.Trigger value="month">30 Days</Tabs.Trigger>
<Tabs.Trigger value="all">All Time</Tabs.Trigger>
</Tabs.List>
<Tabs.Content value="month">…</Tabs.Content>
</Tabs.Root>ToggleGroup · A setting with two or three values.
import * as ToggleGroup from '#lib/components/ui/toggle-group/index.js';
<ToggleGroup.Root type="single" bind:value={view}>
<ToggleGroup.Item value="cards">Cards</ToggleGroup.Item>
<ToggleGroup.Item value="list">List</ToggleGroup.Item>
</ToggleGroup.Root>