ButtonGroup
When to use it
Section titled “When to use it”- At the end of a dialog or form, to pair the main action with a way out, such as “Publish review” and “Save as draft”, or “Save role and access” and “Cancel”.
- Use type destructive when the main action deletes or cancels something, such as “Continue to cancel” and “Keep my booking”.
- Use type secondary for two actions of equal weight, such as “View” and “Modify” on a trip card.
- Use layout stack on narrow screens such as the mobile app, with the main action on top.
- Use type segmented to switch a view between 2 to 4 options, such as the time range “Last 24 hours / 7 days / 30 days / Custom range” on the back office dashboard. Exactly one segment is selected.
When not to use it
Section titled “When not to use it”- For a single action: use the Button component instead.
Instead: Button - To filter a list by several values at once: use the Chip component instead. Segments pick exactly one option.
Instead: Chip - For more than three actions, or more than four segments: move the extras into a Dropdown component.
Instead: Dropdown
Best practice
Section titled “Best practice”From the Figma documentation page (usage node 193:59), as written. These items aren’t carried into ButtonGroup.intent.json, which has no field for them.
- Put the main action first: on the left in a row, on top in a stack.
- Use at most one filled button per group; the others are outline.
- Label buttons with what they do (“Delete account”, “Keep my account”), not “Yes” and “No”.
- Keep the whole group together; don’t split its buttons across the layout.
- In a destructive group, make the safe choice easy to find and never the filled button.
What each variant is for
Section titled “What each variant is for”| Property | Value | What it is for |
|---|---|---|
type |
primary |
primary (filled + outline, default) |
type |
destructive |
destructive (error + outline) |
type |
secondary |
secondary (two outlines) |
type |
segmented |
segmented (2 to 4 options, one selected in navy, the rest outlined; row only) |
layout |
row |
row (default, main action on the left) |
layout |
stack |
stack (full width, main action on top; not for segmented) |
Accessibility
Section titled “Accessibility”- The button types render a role=“group” container; callers name it with aria-label (spread onto the div).
src/components/ButtonGroup/ButtonGroup.tsx:71 - The button types compose the native Button, so each action is a real <button> with its visible text as its accessible name.
src/components/ButtonGroup/ButtonGroup.tsx:76 - The segmented type renders a role=“radiogroup” container; callers name it with aria-label.
src/components/ButtonGroup/ButtonGroup.tsx:109 - Each segment is a native <input type=“radio”> inside a <label>, all sharing one name, so exactly one is selected and arrow-key behaviour is the browser’s own; aria-pressed is not used.
src/components/ButtonGroup/ButtonGroup.tsx:119 - The radio input is transparent (not display:none), so it stays focusable and exposed to assistive technology while the label draws the segment.
src/components/ButtonGroup/ButtonGroup.css:49 - Keyboard focus on a segment shows the browser’s native focus ring on its label, via :has(input:focus-visible).
src/components/ButtonGroup/ButtonGroup.css:63
What this version promises
Section titled “What this version promises”From Versioning (VERSIONING.md at b9ffb76):
0.3.0 adds six components on top of 0.2.1: Calendar, Card, Form, Modal, SideBar and Table. It contains twenty-three components, each exported from the package root with its props type: Avatar, Breadcrumbs, Button, ButtonGroup, Calendar, Card, Checkbox, Chip, Dropdown, File, Form, Header, Image, Link, Logo, Modal, ProgressBar, RadioCard, SearchBar, SideBar, Stepper, Table, Toggle. Textfield is exported from the package root as well, with TextfieldProps and TextfieldState, and is public like the others (see decisions.md, 2026-10-07, Textfield). It commits you to their props, prop values and defaults, their hz- class names, the tokens in tokens.css and the three entry points (., ./styles.css, ./tokens.css). Everything in 0.3.0 beyond 0.2.1 is an addition: nothing from 0.2.1 was changed, removed or renamed. A change that breaks any of these on 0.x bumps the version to 0.4.0.
Two things about this release are worth knowing:
- Form, Modal and Table each passed release review with their literal sizes covered by a ruling in decisions.md (Card, SideBar and Calendar have their own), because no size tokens exist for them. Those literals are accepted until the designer adds matching tokens, so a later change to use tokens at the same rendered sizes would be a patch, not a breaking change.
- Dark theme is not verified for Table, and its warning tag has low contrast. The Table docs page says so. Neither is a breaking-change risk, but a fix that changes a token’s value is a patch and is listed in the changelog.
Stories
Section titled “Stories”All Variants
Section titled “All Variants”The single-variant stories (PrimaryRow, PrimaryStack, DestructiveRow, DestructiveStack, SecondaryRow, SecondaryStack, SegmentedRow) are cells of the variant matrix; the Design tab links each one.
Import
Section titled “Import”import { ButtonGroup } from "@layerbasesystemic/horizon-design-system";import type { ButtonGroupProps, ButtonGroupActionProps, ButtonGroupSegmentedProps, ButtonGroupType, ButtonGroupLayout } from "@layerbasesystemic/horizon-design-system";@layerbasesystemic/horizon-design-system/tokens.css and @layerbasesystemic/horizon-design-system/styles.css must be loaded too; see Developing.
ButtonGroup.tsx is built from Button: it imports it (ButtonGroup.tsx:4) and renders <Button> (ButtonGroup.tsx:76). The registry’s Composes column for ButtonGroup lists Button.
ButtonGroupProps is ButtonGroupActionProps \| ButtonGroupSegmentedProps (ButtonGroup.tsx:55). The type prop decides which one applies; where the two differ, the table shows each.
| Prop | Type | Default | Description |
|---|---|---|---|
showThird |
boolean |
false |
Figma showThird: adds a third button or segment. |
showFourth |
boolean |
none in ButtonGroupActionPropsfalse in ButtonGroupSegmentedProps |
Figma showFourth: adds a fourth segment (segmented only; no effect on the button types). |
labels |
string[] |
— | Not a Figma property. Texts by slot (first, second, third, fourth); defaults are the Figma texts. |
type |
Exclude<ButtonGroupType, "segmented"> in ButtonGroupActionProps"segmented" in ButtonGroupSegmentedProps |
"primary" in ButtonGroupActionPropsnone in ButtonGroupSegmentedProps |
primary (default), destructive or secondary: composed from Button. |
layout |
ButtonGroupLayout in ButtonGroupActionProps"row" in ButtonGroupSegmentedProps |
"row" in ButtonGroupActionPropsnone in ButtonGroupSegmentedProps |
row (default) or stack (full width, main action on top). (ButtonGroupActionProps)Segmented is row only. ( ButtonGroupSegmentedProps) |
onItemClick |
(index: number, event: MouseEvent<HTMLButtonElement>) => void |
— | Not a Figma property. Called when a button is clicked, with its slot index. |
value |
number |
— | Not a Figma property. Selected slot index (controlled). |
defaultValue |
number |
0 |
Not a Figma property. Selected slot index (uncontrolled); default 0. |
onValueChange |
(index: number) => void |
— | Not a Figma property. Called with the slot index of the newly selected segment. |
ButtonGroupActionProps and ButtonGroupSegmentedProps both extend ButtonGroupBaseProps, which extends Omit<HTMLAttributes<HTMLDivElement>, "children" \| "role">, so native attributes pass through to the element (ButtonGroup.tsx:25).
Which props are Figma properties. The Figma properties are type, layout, showThird and showFourth; the table above marks the others “Not a Figma property” from their doc comments. The stories’ header comment says: “Figma properties: type (primary | destructive | secondary | segmented), layout (row | stack), showThird and showFourth (booleans, default false). Figma’s ShowThird / ShowFourth map to the camelCase booleans showThird / showFourth. Not Figma properties (added so the component is usable): labels (texts by slot; Figma edits them inside the instances), onItemClick (button types), value / defaultValue / onValueChange (segmented, selected slot index; default 0 as drawn), plus passthrough div attributes and aria-label.” (ButtonGroup.stories.tsx:4-9).
Text and selection. Figma’s component description (node 191:123) says, unedited: “Edit each button’s or segment’s text, and which segment is selected, from the group’s properties.” The code takes the texts as the labels array (the header comment above says Figma edits them inside the instances) and the selected segment as value, defaultValue and onValueChange.
From the release review, under “Findings outside the gates”, as written:
Props that are not Figma properties. labels (ButtonGroup.tsx:31), onItemClick (:40), value, defaultValue and onValueChange (:48, 50, 52), plus passthrough div attributes including aria-label. They are marked in the source as not Figma properties and added so the component is usable. They are part of the public API once published (a 0.x breaking-change surface for VERSIONING.md). Owner: a human, to accept them as intended API or ask the designer to draw them.
Text editing in Figma. The Usage frame 193:59 contains no line about editing text from the group’s properties, so this review could not confirm it there. The story header says Figma edits the texts inside the instances, which is why labels exists. If the designer means the group should expose its text as properties, that is a design decision, not a gate finding.
Figma property-name casing. The source maps Figma’s ShowThird and ShowFourth (PascalCase, per the story header) to the camelCase booleans showThird and showFourth. type and layout match the cell names (type=primary, layout=row). Button’s precedent (94900ff, “match Figma prop/value names exactly”) argues for the Figma spelling; Breadcrumbs keeps ShowItem2 verbatim in its intent. Owner: a human, to settle one convention. Not a gate finding.
Stack needs a parent with a defined width. ButtonGroup.css sets width: 100%; on the stack layout.
From the QA report, as written:
The stack layout has width: 100%, so it needs a parent with a defined width (in an auto-width parent it collapses to zero); the stories use a 320px wrapper.
From the release review, under “Findings outside the gates”, as written:
Stack needs a parent with a defined width. .hz-buttongroup–stack sets width: 100% (ButtonGroup.css:12), so in an auto-width parent it collapses to zero; the stories use a 320px wrapper (QA report, limitations). Consumers need to know. Not in the intent file; there is no field for it.
Union types
Section titled “Union types”ButtonGroupType: primary, destructive, secondary, segmented
ButtonGroupLayout: row, stack
Tokens it needs
Section titled “Tokens it needs”Every CSS custom property ButtonGroup.css reads, with its value in the token build at b9ffb76.
| Token | Light | Dark |
|---|---|---|
--border-width-sm |
1px |
same as light |
--color-bg-elevated |
#f9fafb |
#4d5361 |
--color-bg-inverse |
#161925 |
#f9fafb |
--color-border-default |
#d7dee7 |
#4d5361 |
--color-text-inverse |
#f9fafb |
#161925 |
--color-text-secondary |
#4d5361 |
#9ca2b1 |
--fontfamily-body |
Inter |
same as light |
--fontsize-xs |
10px |
same as light |
--lineheight-xs |
16px |
same as light |
--radius-xs |
2px |
same as light |
--spacing-md |
12px |
same as light |
--spacing-sm |
8px |
same as light |
This matches required_tokens in ButtonGroup.intent.json exactly.
Figma node
Section titled “Figma node”Page Buttongroups (57:1640), documentation frame ❖ buttongroup (192:44), component set buttongroup (191:123). The file is shared with the team only, so the frame and the link ask anyone outside it to sign in.
The page also holds _buttongroup-segment (194:111), which Figma describes as: “Internal part of buttongroup type=segmented (not for direct use). One option: state unselected or selected.” Its Figma variants: state=unselected (194:107), state=selected (194:109).
Variant matrix
Section titled “Variant matrix”type (4) × layout (2) = 8 combinations, of which Figma publishes 7 cells. The documentation frame (192:44) lays out type (rows: primary, destructive, secondary, segmented) against layout (columns: row, stack). The component set (191:123) publishes 7 variants, named type=primary, layout=row through type=segmented, layout=row. It has no type=segmented, layout=stack variant, so the grid is 4 x 2 = 8 but 7 are published. ShowThird and ShowFourth are boolean properties of the set, not cells; the page draws them as the Examples ShowThird: true (192:58) and ShowThird + ShowFourth: true (195:964). Figma draws no hover, pressed or disabled states.
type |
layout=row |
layout=stack |
|---|---|---|
primary |
PrimaryRow191:3 |
PrimaryStack191:26 |
destructive |
DestructiveRow191:45 |
DestructiveStack191:66 |
secondary |
SecondaryRow191:85 |
SecondaryStack191:104 |
segmented |
SegmentedRow195:44 |
not published in Figma |
Each cell is the Storybook story for that combination and its Figma variant node. ButtonGroupType and ButtonGroupLayout are the union types listed on the Code tab. Figma publishes 7 of the 8 combinations: type=segmented, layout=stack is not published, so the matrix has no cell or story for it. The component description says “stack (full width, main action on top; not for segmented)” (node 191:123). In the code, ButtonGroupSegmentedProps types layout as "row", so segmented + stack is a type error. The stories’ header comment says: “layout=“stack” is not available for type=“segmented” (a type error).” (ButtonGroup.stories.tsx:10). The story that isn’t a single cell (AllVariants) is embedded on the Examples tab.
Themes
Section titled “Themes”The buttongroup frame renders every cell once, in one theme. It has no separate light and dark frames.
The token build defines 179 tokens for light and redeclares 50 for dark; the Code tab shows ButtonGroup’s tokens in both.
Values Figma never bound
Section titled “Values Figma never bound”Values on the Figma node that aren’t bound to a variable, and what ButtonGroup.css at b9ffb76 does with each.
| Layer | Property | Figma value | In the code |
|---|---|---|---|
| buttongroup, layout=stack (191:26, 191:66, 191:104) | width (the code sets width: 100% of the parent, not a width literal) | 320px |
width: 100%; |
| _buttongroup-segment, both states (194:107, 194:109) | vertical padding (the code computes it from –spacing-md with calc(), not a px literal) | 7px |
padding-block: calc(var(--spacing-md) / 2); |
Figma variables against the token build
Section titled “Figma variables against the token build”| Figma variable | Figma value | Token in the build | Built light value | Agrees |
|---|---|---|---|---|
--color-text-inverse |
#f9fafb |
--color-text-inverse |
#f9fafb |
yes |
--fontSize-xs |
10 |
--fontsize-xs |
10px |
yes |
--fontWeight-regular |
Regular |
no such token | — | no token |
--fontFamily-body |
Inter |
--fontfamily-body |
Inter |
yes |
--lineHeight-xs |
16 |
--lineheight-xs |
16px |
yes |
--radius-sm |
6 |
--radius-sm |
6px |
yes |
--color-primary-default |
#3b71f2 |
--color-primary-default |
#2b5ad6 |
no |
--color-text-primary |
#161925 |
--color-text-primary |
#161925 |
yes |
--color-neutral-default |
#8a909c |
--color-neutral-default |
#8a909c |
yes |
--spacing-md |
12 |
--spacing-md |
12px |
yes |
--color-status-error |
#ea3d3d |
--color-status-error |
#d02727 |
no |
--radius-xs |
2 |
--radius-xs |
2px |
yes |
--border-width-sm |
1 |
--border-width-sm |
1px |
yes |
--color-bg-inverse |
#161925 |
--color-bg-inverse |
#161925 |
yes |
--color-text-secondary |
#4d5361 |
--color-text-secondary |
#4d5361 |
yes |
--color-bg-elevated |
#f9fafb |
--color-bg-elevated |
#f9fafb |
yes |
--color-border-default |
#d7dee7 |
--color-border-default |
#d7dee7 |
yes |
--spacing-sm |
8 |
--spacing-sm |
8px |
yes |
--fontWeight-regular is bound in Figma but the token build has no token of that name.
--color-primary-default, --color-status-error hold a different value in Figma from the token of the same name in the build. ButtonGroup.css doesn’t read those tokens, but the stylesheet of the component ButtonGroup is built from does (Button.css), so the Button rendered inside ButtonGroup uses the build’s value, not Figma’s.
Every commit to src/components/ButtonGroup up to b9ffb76, newest first, with the published version that carries it.
| Commit | Date | Version | Change |
|---|---|---|---|
3a701d5 |
2026-10-02 | 0.2.0 | ButtonGroup: intent usage from Figma Usage frame 193:59 |
7f7fdfa |
2026-10-02 | 0.2.0 | ButtonGroup: row layouts hug content (inline-flex), stack stays full width |
f302205 |
2026-10-02 | 0.2.0 | ButtonGroup: build from Figma 191:123 |