ButtonGroup
ActionsButtons joined into one control. <ButtonGroup.Root> (orientation: horizontal or vertical) holds Buttons, triggers, an Input, a ButtonGroup.Text (a label or unit in a box) and ButtonGroup.Separators, and joins them: square inner corners, one border between neighbours. It is a group; name it with aria-label. Groups inside a group keep a gap.
import { ButtonGroup } from '@limerdev/zest'; ToggleGroup. A row of unrelated actions: put Buttons side by side with a gap. Tabs between views: use Tabs.Examples
Split button
A split button: the action, and a menu of its other ways.
<script lang="ts">
import { Button, ButtonGroup, DropdownMenu } from '@limerdev/zest';
import ChevronDownIcon from '@lucide/svelte/icons/chevron-down';
</script>
<ButtonGroup.Root aria-label="Send invoice">
<Button>Send</Button>
<ButtonGroup.Separator />
<DropdownMenu.Root>
<DropdownMenu.Trigger size="icon" aria-label="More ways to send">
<ChevronDownIcon aria-hidden="true" />
</DropdownMenu.Trigger>
<DropdownMenu.Content align="end">
<DropdownMenu.Item>Schedule</DropdownMenu.Item>
<DropdownMenu.Item>Send a copy to me</DropdownMenu.Item>
</DropdownMenu.Content>
</DropdownMenu.Root>
</ButtonGroup.Root> Pager
Outline buttons with ButtonGroup.Text between them: one border between neighbours.
<script lang="ts">
import { Button, ButtonGroup } from '@limerdev/zest';
import ChevronLeftIcon from '@lucide/svelte/icons/chevron-left';
import ChevronRightIcon from '@lucide/svelte/icons/chevron-right';
let current: number = $state(2);
const last: number = 5;
</script>
<ButtonGroup.Root aria-label="Pages">
<Button
variant="outline"
size="icon"
aria-label="Previous page"
disabled={current === 1}
onclick={() => current--}
>
<ChevronLeftIcon aria-hidden="true" />
</Button>
<ButtonGroup.Text>Page {current} of {last}</ButtonGroup.Text>
<Button
variant="outline"
size="icon"
aria-label="Next page"
disabled={current === last}
onclick={() => current++}
>
<ChevronRightIcon aria-hidden="true" />
</Button>
</ButtonGroup.Root> With input
An Input and its action, joined. Groups inside a group keep a gap.
<script lang="ts">
import { Button, ButtonGroup, Input } from '@limerdev/zest';
import PlusIcon from '@lucide/svelte/icons/plus';
import MinusIcon from '@lucide/svelte/icons/minus';
</script>
<ButtonGroup.Root aria-label="Invite and zoom">
<ButtonGroup.Root aria-label="Invite">
<Input aria-label="Email" type="email" placeholder="name@example.com" class="w-56" />
<Button variant="outline">Invite</Button>
</ButtonGroup.Root>
<ButtonGroup.Root aria-label="Zoom">
<Button variant="outline" size="icon" aria-label="Zoom out">
<MinusIcon aria-hidden="true" />
</Button>
<Button variant="outline" size="icon" aria-label="Zoom in">
<PlusIcon aria-hidden="true" />
</Button>
</ButtonGroup.Root>
</ButtonGroup.Root> Vertical
orientation="vertical" stacks the buttons.
<script lang="ts">
import { Button, ButtonGroup } from '@limerdev/zest';
</script>
<ButtonGroup.Root orientation="vertical" aria-label="Align">
<Button variant="outline">Top</Button>
<Button variant="outline">Middle</Button>
<Button variant="outline">Bottom</Button>
</ButtonGroup.Root> Props
Every part also takes class (merged over its defaults), ref (bindable: the element), children, and child (a snippet that
renders your own element, with props to spread on it).
ButtonGroup.Root
| Prop | Type | Default | Description |
|---|---|---|---|
| orientation | "horizontal" | "vertical" | 'horizontal' | Which way the buttons run: side by side, or stacked. |
ButtonGroup.Text
No props of its own beyond the common ones.
ButtonGroup.Separator
| Prop | Type | Default | Description |
|---|---|---|---|
| decorative | boolean | true | Whether the separator is decorative and should be hidden from assistive technologies. |
| orientation | "horizontal" | "vertical" | 'vertical' | The orientation of the separator. |