Button Group
NewJoin related buttons, inputs, and text into a single control.
Preview
Installation
npx sigma-ui@latest add button-groupUsage
<script setup lang="ts">
import { Button } from '@/components/ui/button';
import { ButtonGroup } from '@/components/ui/button-group';
</script>
<template>
<ButtonGroup>
<Button variant="outline">Archive</Button>
<Button variant="outline">Report</Button>
</ButtonGroup>
</template>ButtonGroup joins its children by removing the inner borders and corner radii. Set orientation to horizontal or vertical. Nest groups to add spacing between them.
ButtonGroupTextis static text or an icon inside the group, such as a URL prefix. Useas-childto render aLabel.ButtonGroupSeparatordivides buttons that have no border, such as thesecondaryvariant.
Examples
Orientation
With input
Inputs grow to fill the free space in the group. Wrap ButtonGroupText around a Label with as-child to label the input.
Separator
API Reference
ButtonGroup
Props
| Prop | Type | Default |
|---|---|---|
orientationDirection in which the buttons are joined. | "vertical" | "horizontal" | null | "horizontal" |
Slots
| Slot | Scope |
|---|---|
defaultButtons, inputs, | - |
ButtonGroupSeparator
Props
| Prop | Type | Default |
|---|---|---|
orientationOrientation of the component. Either | DataOrientation | "vertical" |
decorativeWhether or not the component is purely decorative. <br>When | boolean | - |
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
ButtonGroupText
Props
| Prop | Type | Default |
|---|---|---|
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Slots
| Slot | Scope |
|---|---|
defaultStatic text or an icon, such as a URL prefix or a unit. | - |
Accessibility
ButtonGroup renders role="group". Set aria-label or aria-labelledby to describe what the buttons do together. Use ToggleGroup instead when the buttons toggle a state.
A focused child is raised above its siblings, so the focus ring is not hidden behind the next button.
| Key | Description |
|---|---|
| Tab | Moves focus between the controls in the group. |
| Enter or Space | Activates the focused button. |