← All Components
<mth-tag>
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
Ready · interact with <mth-tag>, or toggle Theme, Direction (LTR/RTL), or props above.
Live Variants & States Showcase
semantic variantsNeutral Accent Success Warning Danger
interactive & selectedFilter Selected
removable & pillCSS OKLCH
disabledDisabled Tag
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/ui/tag"></script>
<mth-tag variant="neutral" size="sm">Example</mth-tag>import '@methane-ui/ui/tag';
import '@methane-ui/react';
export function Example() {
return <mth-tag variant="neutral" size="sm">Example</mth-tag>;
}<script setup lang="ts">
import '@methane-ui/ui/tag';
</script>
<template>
<mth-tag variant="neutral" size="sm">Example</mth-tag>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/ui/tag';
import { MthTagDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthTagDirective],
template: `<mth-tag variant="neutral" size="sm">Example</mth-tag>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/ui/tag';
import MthTag from '@methane-ui/svelte/MthTag.svelte';
</script>
<MthTag variant="neutral" size="sm">Example</MthTag>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
variant | variant | 'neutral' | 'accent' | 'success' | 'warning' | 'danger' | "neutral" | Semantic color variant (neutral, accent, success, warning, danger). |
size | size | 'sm' | 'md' | 'lg' | "md" | Visual size scale (sm, md, lg). |
pill | pill | boolean | false | Applies fully rounded pill corners. |
removable | removable | boolean | false | Renders a dismissal button that emits mth-remove. |
disabled | disabled | boolean | false | Disables interaction and removal. |
interactive | interactive | boolean | false | Renders the tag label inside a native toggleable button. |
selected | selected | boolean | false | Selected state reflected on interactive tags. |
value | value | string | "" | Optional programmatic value included in emitted event details. |
label | label | string | "" | Fallback text label when default slot is empty. |
Events
| Event | Detail Type | Description |
|---|---|---|
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
| Key | Direction | When | Expected Behavior |
|---|---|---|---|
| Enter | both | Interactive tag trigger is focused | Activates tag and emits mth-click |
both | Interactive tag trigger is focused | Activates tag and emits mth-click | |
| Backspace | both | Removable tag is focused | Dispatches cancelable mth-remove |
| Delete | both | Removable tag is focused | Dispatches cancelable mth-remove |
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 4 APG keyboard transitions across LTR/RTL. | mth-tag.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(disabled), :state(removable), :state(selected), :state(interactive). | Conformance suite |
| i18n | Routes 2 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |