Methane@methane-ui/*
CSS LayoutsComponentsSkillsTheme BuilderGitHub
← All Components

<mth-toggle-button>

@methane-ui/ui~6.8 KB brotli (cold + Lit)~1.4 KB marginal

Two-state pressable toggle button exposing aria-pressed and :state(pressed).

When NOT to use: Use a lightweight @methane-ui/css layout class instead of a custom element when static CSS suffices.

Live Interactive Preview

Interactive StageLive Custom Element · <mth-toggle-button> (@methane-ui/ui)
Pin Workspace
Ready · interact with <mth-toggle-button>, or toggle Theme, Direction (LTR/RTL), or props above.

Live Variants & States Showcase

variant="outline"Outline
variant="soft"Soft
variant="solid"Solid
variant="ghost"Ghost
pressedActive Toggle
disabledDisabled

Multi-Framework Playground & Snippets

<script type="module" src="@methane-ui/ui/toggle-button"></script>
<mth-toggle-button variant="solid" size="sm">Example</mth-toggle-button>

Properties & Attributes

PropertyAttributeTypeDefaultDescription
pressedpressedbooleanfalseWhether the toggle button is currently pressed.
variantvariant'solid' | 'soft' | 'outline' | 'outlined' | 'ghost'"outline"Visual style (solid, soft, outline / outlined, or ghost).
sizesize'sm' | 'md' | 'lg'"md"Control size (sm, md, or lg).
disableddisabledbooleanfalseDisables interaction and focus.
valuevaluestring""Optional associated value included in mth-change.
labellabelstring""Optional accessible aria-label when using icon-only content.

Events

EventDetail TypeDescription
mth-press{ originalEvent: Event; pressed: boolean }Cancelable event fired when pressed before state toggle.
mth-change{ pressed: boolean; value: string }Cancelable event fired when pressed toggles.

APG Keyboard Matrix

KeyDirectionWhenExpected Behavior
EnterbothButton is focused and enabledToggles pressed state and emits mth-change
bothButton is focused and enabledToggles pressed state and emits mth-change

Accessibility Checklist

CategoryRequirementVerified By
ariaAll aria-* IDREFs resolve within the same DOM root (ADR-003).scanSameRootAria
focusdelegatesFocus: true with zero host internals.role (ADR-014).lint-plugin & spec-compiler
contrastRenders legible borders, focus outlines, and selection indicators under forced-colors: active.Playwright forced-colors matrix
keyboardImplements all 2 APG keyboard transitions across LTR/RTL.mth-toggle-button.spec.test.ts
statesExposes ElementInternals CustomStateSet flags: :state(pressed), :state(disabled).Conformance suite
i18nRoutes 1 UI/ARIA strings through @methane-ui/core i18n catalog.Locale context test