← All Components
<mth-button-group>
Groups related buttons or icon buttons with optional attached styling and toolbar roving focus.
When NOT to use: Use a lightweight @methane-ui/css layout class instead of a custom element when static CSS suffices.
Live Interactive Preview
Ready · interact with <mth-button-group>, or toggle Theme, Direction (LTR/RTL), or props above.
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/ui/button-group"></script>
<mth-button-group orientation="horizontal" role-mode="group">Example</mth-button-group>import '@methane-ui/ui/button-group';
import '@methane-ui/react';
export function Example() {
return <mth-button-group orientation="horizontal" role-mode="group">Example</mth-button-group>;
}<script setup lang="ts">
import '@methane-ui/ui/button-group';
</script>
<template>
<mth-button-group orientation="horizontal" role-mode="group">Example</mth-button-group>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/ui/button-group';
import { MthButtonGroupDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthButtonGroupDirective],
template: `<mth-button-group orientation="horizontal" role-mode="group">Example</mth-button-group>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/ui/button-group';
import MthButtonGroup from '@methane-ui/svelte/MthButtonGroup.svelte';
</script>
<MthButtonGroup orientation="horizontal" role-mode="group">Example</MthButtonGroup>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
orientation | orientation | 'horizontal' | 'vertical' | "horizontal" | Layout and arrow-key navigation axis (horizontal or vertical). |
attached | attached | boolean | false | Visually joins adjacent buttons along the group axis. |
roving | roving | boolean | false | Enables single-tabstop APG roving focus navigation across slotted buttons. |
roleMode | role-mode | 'group' | 'toolbar' | "group" | Semantic host role (group or toolbar). Setting toolbar automatically enables roving focus. |
label | label | string | "" | Accessible aria-label exposed via ElementInternals. |
APG Keyboard Matrix
| Key | Direction | When | Expected Behavior |
|---|---|---|---|
| ArrowRight | ltr | Horizontal roving/toolbar mode is active | Moves focus to the next enabled button |
| ArrowLeft | rtl | Horizontal roving/toolbar mode is active in RTL | Moves focus to the next enabled button |
| ArrowDown | both | Vertical roving/toolbar mode is active | Moves focus to the next enabled button |
| ArrowUp | both | Vertical roving/toolbar mode is active | Moves focus to the previous enabled button |
| Home | both | Roving/toolbar mode is active | Moves focus to the first enabled button |
| End | both | Roving/toolbar mode is active | Moves focus to the last enabled button |
Accessibility Checklist
| Category | Requirement | Verified By |
|---|---|---|
| aria | All aria-* IDREFs resolve within the same DOM root (ADR-003). | scanSameRootAria |
| focus | Focus ownership matches focusModel="none" with host role="group". | lint-plugin & spec-compiler |
| contrast | Renders legible borders, focus outlines, and selection indicators under forced-colors: active. | Playwright forced-colors matrix |
| keyboard | Implements all 6 APG keyboard transitions across LTR/RTL. | mth-button-group.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(attached), :state(vertical), :state(roving). | Conformance suite |