Button Group
Alignment target:@astryxdesign/core v0.7.1 · ButtonGroup
Usage #
ButtonGroup connects related buttons into one group. Buttons have no gap. Separators distinguish adjacent buttons:
<script setup lang="ts">
import { Button } from '@astryx-vue/core/Button'
import { ButtonGroup } from '@astryx-vue/core/ButtonGroup'
</script>
<template>
<ButtonGroup label="Editing actions">
<Button label="Copy" />
<Button label="Cut" />
<Button label="Paste" />
</ButtonGroup>
</template>On a touch-first device such as a phone or tablet, a press tracks like a menu for a finger or a pen: press a button and slide across the others, and the highlight follows. The button you lift on runs, and lifting outside the group runs nothing. A mouse press acts as a native button's. A menu trigger in the group (with aria-haspopup) keeps its own opening. The group grows its buttons' tap targets toward 44 px, stopping halfway to the nearest interactive neighbor outside the group; a tap in that band goes to the nearest button.
Anatomy
| Element | Description |
|---|---|
| Button | One or more Button or IconButton elements that form the connected group. |
| Divider | A thin border between buttons, rendered automatically by the group. |
Best practices #
| Guidance | Practices |
|---|---|
| Do | Group buttons that perform related actions on the same object, like copy, cut, paste on selected text. |
| Do | Use the same variant for all buttons in a group so they look like a single connected unit. |
| Do | Keep groups small (2–4 buttons). For more actions, use a Toolbar or DropdownMenu instead. |
Examples #
Button Group — Basic
Three related actions joined into a single connected control. Provide a group label for accessibility and keep all buttons the same variant so they read as one unit.
Button Group — Floating
A grouped action bar raised with elevation="med". The connected buttons share one surface, so the shadow lifts them as a unit.