Button group
Buttons that act on one thing, drawn as one control: a secondary button cut by lines, or ghost buttons in one container.
<ButtonGroup aria-label="Agent actions"> <ButtonGroupItem iconStart={Eye}>Preview</ButtonGroupItem> <ButtonGroupItem iconStart={Copy}>Duplicate</ButtonGroupItem> <ButtonGroupItem iconStart={Trash}>Delete</ButtonGroupItem></ButtonGroup>Installation
import { ButtonGroup, ButtonGroupItem, ButtonGroupText } from "@dome-systems/ds-dashboard/components";Usage
import { ButtonGroup, ButtonGroupItem, ButtonGroupText } from "@dome-systems/ds-dashboard/components";<ButtonGroup aria-label="Agent actions">
<ButtonGroupItem iconStart={Eye}>Preview</ButtonGroupItem>
<ButtonGroupItem iconStart={Copy}>Duplicate</ButtonGroupItem>
<ButtonGroupItem iconStart={Trash}>Delete</ButtonGroupItem>
</ButtonGroup>Anatomy
- 1 — The group. The secondary button's ring, drops and inner highlight, drawn once around every part. Its corners follow the size.
- 2 — Text part. A label or a value on the secondary fill, in quiet text. It does nothing unless it is rendered as a button.
- 3 — Line. A 1px line before every part but the first. It is the group's own, read from where each part sits, never set by hand.
- 4 — Item. A ds Button in the group's variant and size: an icon, a label, or both.
- 5 — Badge. A small Badge after an item's label, never taller than the item.
Variant
Two looks, set once on the group. secondary, the default, is one secondary button cut by lines: the group draws the button's ring, drops and inner highlight once, around all of its items. ghost is one container with the secondary button's surface and 2px of padding, holding ghost items with their own round corners and no line between them. There is no primary group.
<ButtonGroup aria-label="Agent actions"> <ButtonGroupItem iconStart={Eye}>Preview</ButtonGroupItem> <ButtonGroupItem iconStart={Copy}>Duplicate</ButtonGroupItem> <ButtonGroupItem iconStart={Trash}>Delete</ButtonGroupItem></ButtonGroup>
<ButtonGroup variant="ghost" aria-label="Agent actions"> <ButtonGroupItem iconStart={Eye}>Preview</ButtonGroupItem> <ButtonGroupItem iconStart={Copy}>Duplicate</ButtonGroupItem> <ButtonGroupItem iconStart={Trash}>Delete</ButtonGroupItem></ButtonGroup>Size
The Button's four sizes, set on the group and never on an item: md 32px (the default), sm 28, xs 24, xxs 20. The radius follows: 8px at md and sm, 6 at xs, 5 at xxs. In a ghost group the items are 4px shorter than the size, so the container is exactly the size's height. In a card's header or footer a group is 28px at most, as a Button is.
<ButtonGroup size="md" aria-label="History">…</ButtonGroup><ButtonGroup size="sm" aria-label="History">…</ButtonGroup><ButtonGroup size="xs" aria-label="History">…</ButtonGroup><ButtonGroup size="xxs" aria-label="History">…</ButtonGroup>Orientation
horizontal by default. vertical stacks the items, with the line under each instead of beside it; the group is as wide as its widest item.
<ButtonGroup orientation="vertical" aria-label="Zoom"> <ButtonGroupItem iconStart={Plus} aria-label="Zoom in" /> <ButtonGroupItem iconStart={Pause} aria-label="Fit" /></ButtonGroup>Items
A ButtonGroupItem is the ds Button in the group's variant and size, so it takes the Button's own props: iconStart, iconEnd, the label, tooltip, disabled, onClick. With no label it is icon-only, a square at the group's size, and needs a name: an aria-label, or its tooltip's text.
<ButtonGroup aria-label="Run"> <ButtonGroupItem iconStart={Play} tooltip="Run now" /> <ButtonGroupItem iconStart={Pause} tooltip="Pause" /> <ButtonGroupItem iconStart={Share} tooltip="Share" disabled /></ButtonGroup>Text part
ButtonGroupText is a label or a value inside the group: the secondary fill and quiet text. It is not a button and does nothing unless render makes it one. Use it to say what the buttons beside it act on.
<ButtonGroup aria-label="Status filter"> <ButtonGroupText>Status</ButtonGroupText> <ButtonGroupItem>is</ButtonGroupItem> <ButtonGroupItem>Active</ButtonGroupItem></ButtonGroup>Badge
An item's badge puts a small ds Badge after its label: a count, a status. It takes the Badge's own shape (label, color, emphasis, iconStart, iconEnd, title), neutral and low unless it says otherwise. The badge is never taller than its item.
<ButtonGroup aria-label="Review"> <ButtonGroupItem badge={{ label: "3" }}>Suggestions</ButtonGroupItem> <ButtonGroupItem badge={{ label: "New", color: "info" }}>Changes</ButtonGroupItem></ButtonGroup>Loading
An item's loading shows the Loader and stops it firing, and loadingPlacement says where, both as on a Button. With an icon: icon (the default), in the icon's place, or replace, in place of everything. With none: replace (the default), in place of the label, or before, before it. Only before changes the item's width.
<ButtonGroup aria-label="Deploy"> <ButtonGroupItem iconStart={Play} loading>Deploy</ButtonGroupItem> <ButtonGroupItem loading loadingPlacement="before">Saving</ButtonGroupItem> <ButtonGroupItem>Cancel</ButtonGroupItem></ButtonGroup>With a menu
What a split button is for: the main action, then an icon-only item with the small chevron that opens a Dropdown menu of the others. The item is passed to the trigger's render, never wrapped in another element, so it stays one of the group's parts and keeps its corners and its line while the menu is open.
<ButtonGroup aria-label="Duplicate"> <ButtonGroupItem iconStart={Copy}>Duplicate</ButtonGroupItem> <DropdownMenu> <DropdownMenuTrigger render={<ButtonGroupItem iconStart={ChevronDownSmall} aria-label="More ways to duplicate" />} /> <DropdownMenuContent align="end"> <DropdownMenuItem>Duplicate to another workspace</DropdownMenuItem> <DropdownMenuItem>Duplicate with its grants</DropdownMenuItem> </DropdownMenuContent> </DropdownMenu></ButtonGroup>Nested groups
A group of groups keeps its clusters apart: the outer group draws no ring of its own and sets its groups 8px from each other. Use it for a toolbar whose actions fall into sets.
<ButtonGroup aria-label="Run controls"> <ButtonGroup aria-label="History"> <ButtonGroupItem iconStart={ArrowLeft} aria-label="Previous run" /> <ButtonGroupItem iconStart={ArrowRight} aria-label="Next run" /> </ButtonGroup> <ButtonGroup aria-label="This run"> <ButtonGroupItem iconStart={Play}>Run again</ButtonGroupItem> <ButtonGroupItem iconStart={Share}>Share</ButtonGroupItem> </ButtonGroup></ButtonGroup>In the dashboard
Where groups are drawn today: in filters, and nowhere else yet. The dashboard's own components/ui/button-group.tsx renders this group. No screen uses a group for a row of actions so far; the examples above are what it is built for.
A filter chip
What a list is filtered by, as one control: the field, the condition, the value, and an x to remove it.
ds/components/filters.tsx
The older filter builder
The same chip in the product's current filter bar, fusing its own buttons and an input in a secondary group.
components/reui/filters/filters-chip.tsx
A value between two bounds
The older builder's editors fuse inputs and a word between them in one secondary group: a number or a date from one value to another.
components/reui/filters/filters-editors.tsx
API Reference
ButtonGroup
Besides these, every prop of a <div>. It renders role="group": give it an aria-label.
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "secondary" | "ghost" | "secondary" | secondary: fused buttons under one ring, a line between them. ghost: ghost items in one container with the secondary button's surface. |
size | "md" | "sm" | "xs" | "xxs" | "md" | The group's height and its items': 32, 28, 24, 20px. |
orientation | "horizontal" | "vertical" | "horizontal" | A row of items, or a stack. |
aria-label | string | — | The group's name. Required in practice: the group is announced by it. |
ButtonGroupItem
The ds Button without its variant and size, which are the group's. Every other Button prop passes through.
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | — | The label. Without one the item is icon-only and needs an aria-label or a tooltip. |
iconStart | IconComponent | — | An icon before the label, or the item's only content. |
iconEnd | IconComponent | — | An icon after the label: the small chevron on an item that opens a menu. |
badge | BadgeSpec | — | A small Badge after the label, before iconEnd: { label, color?, emphasis?, iconStart?, iconEnd?, title? }. |
tooltip | string | ButtonTooltip | — | Shown on hover and focus. On an icon-only item its text is also the item's name. |
loading | boolean | false | Shows the Loader and stops the item firing; it keeps the focus. |
loadingPlacement | "icon" | "replace" | "before" | "icon" with an icon, "replace" with none | Where the Loader goes, as on a Button. With an icon: in its place, or in place of everything. With none: in place of the label, or before it. |
disabled | boolean | false | The item does nothing and is dimmed. |
render | ReactElement | — | Another element in the item's look: a link. |
ButtonGroupText
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | — | A label or a value: text, with an icon before it if it helps. |
render | ReactElement | — | Makes it another element, such as a button that opens a popover. Without it the part does nothing. |
Rules
Open questions
How many items before a menu takes over?
OpenNothing is enforced. "No more than four" was said in passing and never written down.
Polaris says to limit how many actions a group shows, and allows up to six only when they are icons with no text. Primer's ActionBar moves what does not fit into an overflow menu. shadcn/ui and Atlassian name no number.
Should a group be able to fill its row?
OpenA group is as wide as its items. No screen asks for equal-width items today.
Polaris has a fullWidth option: the buttons stretch or shrink to take the whole width.
Is an input a part of a group?
OpenIt works in a secondary group and the older filter builder relies on it, but no example here shows it and a ghost group cannot hold one.
shadcn/ui documents inputs, selects and input groups inside a button group as first-class uses.
What does a destructive item look like?
OpenThere is no red item. Delete in a group is a plain item, and the confirmation it opens carries the warning.
Atlassian asks for one kind of button per group, which leaves no room for a red one. The other pages read say nothing on it.
When to group
Group actions on one thing
Fusing buttons says they belong together: they act on the same object, or they are steps of one task. Actions that only happen to sit near each other stay separate buttons with a gap.
From Atlassian: actions that are closely related and used often; Polaris: group related calls to action; shadcn/ui: a group is for actions.
Not for choosing a state
A group's items do something and return to rest. When the buttons pick one of several views or switch a setting, use a Toggle group or Tabs: they show what is chosen and say it to a screen reader.
From shadcn/ui: actions go in a button group, states that stay on go in a toggle group.
Not for a table's bulk actions
What you can do to the rows you ticked is not a button group. A table puts its bulk actions under one Actions menu, or shows at most two of them as separate buttons.
The primary action stands alone
There is no primary group, and no item can be primary. A primary action is its own button, beside the group.
One look
One variant and one size for the whole group
variant and size belong to the group, and an item cannot set its own. A bar of controls also keeps one variant: everything on it is secondary, or everything is ghost.
From Atlassian: one kind of button per group.
Items
An icon-only item has a name
Give an icon-only item a tooltip or an aria-label that says what it does, not what it shows: "Run now", not "Triangle".
A split button is an item and a chevron
There is no split button component. The pattern is two items: the action people want most, and an icon-only item with the small chevron, ChevronDownSmall, as a Dropdown menu's trigger.
Short, parallel labels
A group is as wide as its labels, so a long one pushes every other item along. One or two words each.
From Atlassian: short labels that say what the button does.
Built with the group
A trigger is the item, never a wrapper around it
An item that opens a Dropdown menu or a Popover goes in the trigger's render. A part's place (first, between, last) is read from the group's direct children that carry a data-slot; a wrapper without one takes the item out of the count, and its corners and line go wrong. Never set corners or the line by hand.
Only items in a ghost group
A ghost group holds ButtonGroupItems and nothing else: a plain Button there gets neither the ghost item's size nor its fills. A secondary group can also hold a plain Button or an Input as a part.
A badge is the item's prop
Put a count or a status on an item with badge, not with a Badge among its children: the prop sizes the badge to the item and places it before iconEnd.
Hover and pressed are the group's own
An item's fills are tokens of the group (ds/tokens/button-group.css). Do not restyle an item's hover with a class. A secondary item hovers as the secondary button does; a ghost item sits on the container's fill and has its own.
Accessibility
The group is role="group", so a screen reader announces it as a set when focus enters it. Name it with aria-label ("Agent actions"), or aria-labelledby when a visible heading already says it.
Each item is a real button and its own tab stop: Tab moves through the items in order, Enter and Space press one. The arrow keys do nothing here. A group is not a toolbar, and its items are few enough to tab through.
An icon-only item has no visible words, so it must carry a name: an aria-label, or a tooltip, whose text also becomes its name. The tooltip shows on hover and on keyboard focus.
A focused item is raised above its neighbours so its focus ring is never cut by the next item. A loading item keeps the focus and says it is busy (aria-busy); it does not fire while it loads. A press does not shrink an item: the pressed fill says it is held.
The lines between items, the group's ring and its inner highlight are drawn, not elements: nothing extra is read aloud or takes focus.
What others expose
What shadcn/ui, Atlassian, Polaris and Primer offer on their button groups that ours does not, and what we did with each. Base UI, which our components sit on, has no button group; its Toolbar is the nearest thing and is a different control, walked with the arrow keys. Each line was read on that system's own page or, for Polaris, in its component's source.
| They expose | Who | Ours |
|---|---|---|
| A separator part between buttons | shadcn/ui | Not needed. The group draws its own line between parts, from where each sits, and a ghost group has none by design. |
| Inputs, selects and input groups as parts | shadcn/ui | Works, not promoted. A part is any child with a data-slot, so an Input or a plain Button fits a secondary group (the older filter builder does it). See the open question. |
| Buttons that stretch to fill the row | Polaris (fullWidth) | Ask. Nothing in the dashboard needs it yet; see the open question. |
| Spacing between separate buttons | Polaris (gap) | Not needed. Separate buttons are a flex row with a gap; this component is for fused ones. Nested groups cover clusters, 8px apart. |
| A primary button in the group | Atlassian | Not needed. A group has one look and no primary: a page's primary action stands alone, outside the group. |
| Overflow into a menu when out of room | Primer (ActionBar) | Ask. Today a group never wraps or hides items; see the open question. |
| A switch to stop the buttons wrapping | Polaris (noWrap) | Not needed. A group never wraps: it is one control. |
| Right-to-left layout | shadcn/ui | Not needed yet. The dashboard is left-to-right only; the corner and line rules would need logical sides. |
| Only two sizes | Primer | We keep the Button's four, so a group matches whatever sits beside it. |