← All Components
<mth-toggle-group>
Form-associated single or multi-select toggle button group with roving focus, RTL awareness, and FACE validation.
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-toggle-group>, or toggle Theme, Direction (LTR/RTL), or props above.
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/ui/toggle-group"></script>
<mth-toggle-group orientation="horizontal" size="sm">Example</mth-toggle-group>import '@methane-ui/ui/toggle-group';
import '@methane-ui/react';
export function Example() {
return <mth-toggle-group orientation="horizontal" size="sm">Example</mth-toggle-group>;
}<script setup lang="ts">
import '@methane-ui/ui/toggle-group';
</script>
<template>
<mth-toggle-group orientation="horizontal" size="sm">Example</mth-toggle-group>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/ui/toggle-group';
import { MthToggleGroupDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthToggleGroupDirective],
template: `<mth-toggle-group orientation="horizontal" size="sm">Example</mth-toggle-group>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/ui/toggle-group';
import MthToggleGroup from '@methane-ui/svelte/MthToggleGroup.svelte';
</script>
<MthToggleGroup orientation="horizontal" size="sm">Example</MthToggleGroup>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
name | name | string | "" | Form submission field name. |
value | value | string | "" | Selected value (or comma-separated values when multiple is true). |
defaultValue | default-value | string | "" | Initial value restored on form reset. |
label | label | string | "" | Accessible label for the toggle group. |
hint | hint | string | "" | Helper text linked via aria-describedby. |
error | error | string | "" | Explicit validation error message. |
multiple | multiple | boolean | false | Allows toggling multiple pressed items simultaneously. |
orientation | orientation | 'horizontal' | 'vertical' | "horizontal" | Roving focus orientation (horizontal or vertical). |
size | size | 'sm' | 'md' | 'lg' | "md" | Visual button size (sm, md, or lg). |
disabled | disabled | boolean | false | Disables all items in the group. |
required | required | boolean | false | Requires at least one selected item for form submission. |
options | — | ReadonlyArray<unknown> | null | null | Imperative array of toggle items. |
Events
| Event | Detail Type | Description |
|---|---|---|
mth-change | { value: string; values: ReadonlyArray<string> } | Fired when toggle selection changes. |
APG Keyboard Matrix
| Key | Direction | When | Expected Behavior |
|---|---|---|---|
| ArrowRight | ltr | focused horizontal group | moves focus to next item |
| ArrowLeft | rtl | focused horizontal group | moves focus to next item in RTL |
| ArrowDown | both | focused vertical group | moves focus to next item |
| Home | both | focused on any item | moves focus to first enabled item |
| End | both | focused on any item | moves focus to last enabled item |
| Enter / Space | both | focused on an item | toggles selection and updates value |
Accessibility Checklist
| Category | Requirement | Verified By |
|---|---|---|
| aria | All aria-* IDREFs resolve within the same DOM root (ADR-003). | scanSameRootAria |
| focus | delegatesFocus: true with zero host internals.role (ADR-014). | 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-toggle-group.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(dirty), :state(touched), :state(user-invalid), :state(disabled), :state(required). | Conformance suite |
| i18n | Routes 2 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |