Button Group
Groups buttons with connected borders. Use it purely for visual grouping, or as a radio-like segmented control that emits a composed change event.
Preview
<esa-button-group>
<EsaButton variant="primary">Day</EsaButton>
<EsaButton variant="primary">Week</EsaButton>
<EsaButton variant="primary">Month</EsaButton>
</esa-button-group> import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@esa/ecology/esa-button-group';
@Component({
selector: 'app-button-group-demo',
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `
<esa-button-group>
<button type="button">Day</button>
<button type="button">Week</button>
<button type="button">Month</button>
</esa-button-group>
`,
})
export class ButtonGroupDemo {} The group has no size of its own — set size on each child
button, alongside its variant. The group only connects the borders.
Modes
selection-mode="none" is the default — buttons are visually connected but each acts independently.
<esa-button-group selection-mode="none">
<EsaButton variant="primary">Day</EsaButton>
<EsaButton variant="primary">Week</EsaButton>
<EsaButton variant="primary">Month</EsaButton>
</esa-button-group> import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@esa/ecology/esa-button-group';
@Component({
selector: 'app-button-group-modes-demo',
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `
<esa-button-group selection-mode="none">
<button type="button">Day</button>
<button type="button">Week</button>
<button type="button">Month</button>
</esa-button-group>
`,
})
export class ButtonGroupModesDemo {} selection-mode="single" turns the group into a segmented control. One child stays active; give each child a data-value and listen for the change event.
Selected: week
<esa-button-group selection-mode="single" value="week">
<button class="seg-btn" data-value="day">Day</button>
<button class="seg-btn" data-value="week">Week</button>
<button class="seg-btn" data-value="month">Month</button>
</esa-button-group> import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@esa/ecology/esa-button-group';
@Component({
selector: 'app-button-group-demo',
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `
<esa-button-group selection-mode="single" value="week">
<button class="seg-btn" data-value="day">Day</button>
<button class="seg-btn" data-value="week">Week</button>
<button class="seg-btn" data-value="month">Month</button>
</esa-button-group>
`,
})
export class ButtonGroupDemo {} API
| Prop | Type | Default | Description |
|---|---|---|---|
selection-mode | 'none' | 'single' | 'none' | 'none' is visual grouping only; 'single' acts as a radio-like segmented control with one active child. Property: `selectionMode`. |
value | string | '' | In 'single' mode, the data-value of the currently selected child. |
Events
| Event | Type | Default | Description |
|---|---|---|---|
change | CustomEvent<{ value: string }> | — | Fired in 'single' mode when the active child changes. Composed and bubbling; detail.value is the selected child's data-value (falling back to its text content). |
Binding these events from Angular
Every one of these is a CustomEvent, so the payload is on
$event.detail — $event.target.value reads empty, with no
error. The names are lowercase and Angular passes them to
addEventListener verbatim, so camel-casing one means it never fires.
(change)="onChange($event.detail)"
Accessibility
- The host sets
role="group"automatically on connect. - In
singlemode the active child receivesaria-pressed="true"and adata-selectedattribute for styling; the rest getaria-pressed="false". - The
changeevent iscomposedandbubbles, so it crosses shadow boundaries and can be caught on the host or an ancestor. - Slotted children remain real
<button>elements — keyboard focus and activation come for free.
Theming surface
Every public token this component reads, extracted from its source at build time,
split by blast radius: the hooks that belong to this component,
then the shared and system tokens it consumes alongside everything else. The
Resolves to column walks each token's real lineage —
component → semantic → primitive → raw value — so you
can see exactly where re-pointing it lands. A spoke re-skins by overriding these in
its theme-<slug>.css; component internals are never edited. No
hook for what you need? File it with /request-lego.
Type roles it names
This component does not set a size, weight, face or tracking of its own — it names a composite, and the composite carries all five. A composite is a class rather than a token, so none of it appears in the tables below; re-theme text by re-pointing the token family, not by editing the component.
| Role | Re-point | Reach |
|---|---|---|
.typography-label-md |
| +33 more componentsesa-app-bar, esa-breadcrumbs, esa-button-toggle, esa-card, esa-checkbox-group, esa-color-picker, esa-combobox, esa-command-palette, esa-confirm-dialog, esa-danger-zone, esa-date-picker, esa-dialog, esa-empty-state, esa-entity-search, esa-file-upload, esa-filter-container, esa-form-field, esa-header-nav, esa-input-tag, esa-link-column, esa-page-header, esa-pillbox, esa-popover, esa-progress-bar, esa-radio-group, esa-range-slider, esa-select, esa-side-dialog, esa-sidebar-nav, esa-stat, esa-text-field, esa-textarea, esa-tooltip |
Wired to this component
None. This component has no hooks of its own — it themes entirely through the shared tokens below, so every override here also moves its siblings.
Shared tokens it reads
Owned by a family or by the semantic layer. Still overridable — but scope the
override (esa-foo { --form-border-color: … }) unless you mean to move
everything that reads it. Reach says what else that is.
| Token | Reach | Resolves to |
|---|---|---|
--button-radius-md | component owned by esa-button · +1 more | 0.5rem via --radius-md → --radius-200 |
--color-border-default | semantic every component | one role per property, so a theme can move the ring's weight and its colour independently. Tier 3's --focus-ring-width now reads this instead of holding a bare 2px, which is the same shape --focus-ring-color has always had (a thin tier-3 alias over a tier-2 role) — width was simply never given the tier-2 half.
*
* This role was rejected once, and the rejection is worth recording because its PREMISE was wrong rather than its reasoning. The argument against an `emphasis` width was that every 2px border in the kit is micro-geometry — spinner rings, the kbd keycap lip, a chevron. The focus ring was not in that enumeration and does not fit it: 33 components render it, more than read any other tier-3 token, and it is not micro-geometry but an accessibility affordance whose weight is a legitimate brand axis (a spoke that needs a heavier ring for contrast has to be able to reach it). It is also not a `border` in any component — every consumer paints it with `outline` or `box-shadow` — which is precisely why a survey of BORDERS missed it. The name still says `border` because tier 2 already calls the ring's colour --color-border-default-focus |