Components
Button Group
Joins related buttons into a single segmented control.
Installation
$ npx veil-ui@latest add button-groupUsage
import { ButtonGroup } from "@/components/ui/button-group";
import { Button } from "@/components/ui/button";
<ButtonGroup aria-label="Pagination">
<Button variant="outline">Previous</Button>
<Button variant="outline">Next</Button>
</ButtonGroup>;Examples
Basic
Vertical
With icons
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| orientation | "horizontal" | "vertical" | "horizontal" | Direction the grouped buttons flow. |
| aria-label | string | — | Names the group for assistive technology. |
| ...props | React.ComponentProps<"div"> | — | All native div attributes. |
Accessibility
- Renders
role="group"so screen readers announce the grouping. - Always pass an
aria-labelthat describes the set, such as “Pagination”. - Focus rings stay visible; overflow is avoided with overlapping negative margins rather than clipped outlines.
Vue and plain HTML
This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add button-group --framework vue or switch the framework in components.json.
<script setup lang="ts">
import { cn } from "@/lib/utils";
const props = withDefaults(
defineProps<{
orientation?: "horizontal" | "vertical";
class?: string;
}>(),
{ orientation: "horizontal" },
);
</script>
<template>
<div
data-slot="button-group"
:data-orientation="orientation"
role="group"
:class="
cn(
'inline-flex w-fit items-stretch',
orientation === 'horizontal' &&
'[&>*]:rounded-none [&>*:first-child]:rounded-l-md [&>*:last-child]:rounded-r-md [&>*:not(:first-child)]:-ml-px',
orientation === 'vertical' &&
'flex-col [&>*]:rounded-none [&>*:first-child]:rounded-t-md [&>*:last-child]:rounded-b-md [&>*:not(:first-child)]:-mt-px',
props.class,
)
"
>
<slot />
</div>
</template>