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 color="secondary">Day</EsaButton>
<EsaButton color="secondary">Week</EsaButton>
<EsaButton color="secondary">Month</EsaButton>
</esa-button-group> Modes
selection-mode="none" is the default — buttons are visually connected but each acts independently.
<esa-button-group selection-mode="none">
<EsaButton color="secondary">Day</EsaButton>
<EsaButton color="secondary">Week</EsaButton>
<EsaButton color="secondary">Month</EsaButton>
</esa-button-group> 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> 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. |
size | 'xs' | 'sm' | 'md' | 'lg' | 'md' | Reflected sizing hint for the group. |
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). |
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.