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

<mth-tag>

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

Compact categorization tag with semantic variants, optional interactive selection, and accessible removal button.

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

Live Variants & States Showcase

semantic variantsNeutralAccentSuccessWarningDanger
interactive & selectedFilterSelected
removable & pillCSSOKLCH
disabledDisabled Tag

Multi-Framework Playground & Snippets

<script type="module" src="@methane-ui/ui/tag"></script>
<mth-tag variant="neutral" size="sm">Example</mth-tag>

Properties & Attributes

PropertyAttributeTypeDefaultDescription
variantvariant'neutral' | 'accent' | 'success' | 'warning' | 'danger'"neutral"Semantic color variant (neutral, accent, success, warning, danger).
sizesize'sm' | 'md' | 'lg'"md"Visual size scale (sm, md, lg).
pillpillbooleanfalseApplies fully rounded pill corners.
removableremovablebooleanfalseRenders a dismissal button that emits mth-remove.
disableddisabledbooleanfalseDisables interaction and removal.
interactiveinteractivebooleanfalseRenders the tag label inside a native toggleable button.
selectedselectedbooleanfalseSelected state reflected on interactive tags.
valuevaluestring""Optional programmatic value included in emitted event details.
labellabelstring""Fallback text label when default slot is empty.

Events

EventDetail TypeDescription
mth-click{ value: string; selected: boolean }Emitted when an interactive tag is activated.
mth-remove{ value: string }Cancelable event emitted when the remove control or Delete/Backspace is activated.

APG Keyboard Matrix

KeyDirectionWhenExpected Behavior
EnterbothInteractive tag trigger is focusedActivates tag and emits mth-click
bothInteractive tag trigger is focusedActivates tag and emits mth-click
BackspacebothRemovable tag is focusedDispatches cancelable mth-remove
DeletebothRemovable tag is focusedDispatches cancelable mth-remove

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-tag.spec.test.ts
statesExposes ElementInternals CustomStateSet flags: :state(disabled), :state(removable), :state(selected), :state(interactive).Conformance suite
i18nRoutes 2 UI/ARIA strings through @methane-ui/core i18n catalog.Locale context test