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

<mth-code-tabs>

@methane-ui/ui~9.0 KB brotli (cold + Lit)~2.6 KB marginal

Accessible multi-snippet code tab switcher supporting slotted or property-driven tabs, roving keyboard navigation, and copy-to-clipboard.

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-code-tabs> (@methane-ui/ui)
Ready · interact with <mth-code-tabs>, or toggle Theme, Direction (LTR/RTL), or props above.

Multi-Framework Playground & Snippets

<script type="module" src="@methane-ui/ui/code-tabs"></script>
<mth-code-tabs show-copy>Example</mth-code-tabs>

Properties & Attributes

PropertyAttributeTypeDefaultDescription
valuevaluestring""Active tab identifier.
labellabelstring""Accessible label for the internal tablist.
tabs—ReadonlyArray<unknown> | nullnullOptional programmatic array of code tab definitions.
showCopyshow-copybooleantrueWhether to display the copy-to-clipboard button.

Events

EventDetail TypeDescription
mth-change{ value: string }Dispatched when the active code tab changes.
mth-copy{ value: string; code: string; ok: boolean }Dispatched after the copy button copies or attempts to copy the active snippet.

APG Keyboard Matrix

KeyDirectionWhenExpected Behavior
ArrowRightltrA code tab has focusMoves focus and activates the next code tab
ArrowLeftrtlA code tab has focus in RTLMoves focus and activates the next code tab
HomebothAny code tab has focusMoves focus and activates the first code tab
EndbothAny code tab has focusMoves focus and activates the last code tab

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 4 APG keyboard transitions across LTR/RTL.mth-code-tabs.spec.test.ts
i18nRoutes 7 UI/ARIA strings through @methane-ui/core i18n catalog.Locale context test