← All Components
<mth-badge>
Compact status, count, or category indicator badge with variant, size, pill, and dot modes.
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-badge>, or toggle Theme, Direction (LTR/RTL), or props above.
Live Variants & States Showcase
neutral / accent / successNeutral Accent Success
warning / dangerWarning Danger
pill & dotv2.0 Online Alert
sizes (sm / md / lg)SM MD LG
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/ui/badge"></script>
<mth-badge variant="neutral" size="sm">Example</mth-badge>import '@methane-ui/ui/badge';
import '@methane-ui/react';
export function Example() {
return <mth-badge variant="neutral" size="sm">Example</mth-badge>;
}<script setup lang="ts">
import '@methane-ui/ui/badge';
</script>
<template>
<mth-badge variant="neutral" size="sm">Example</mth-badge>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/ui/badge';
import { MthBadgeDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthBadgeDirective],
template: `<mth-badge variant="neutral" size="sm">Example</mth-badge>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/ui/badge';
import MthBadge from '@methane-ui/svelte/MthBadge.svelte';
</script>
<MthBadge variant="neutral" size="sm">Example</MthBadge>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 badge size scale (sm | md | lg). |
pill | pill | boolean | false | Applies fully rounded pill corners. |
dot | dot | boolean | false | Renders as a compact status dot indicator without text. |
Accessibility Checklist
| Category | Requirement | Verified By |
|---|---|---|
| aria | All aria-* IDREFs resolve within the same DOM root (ADR-003). | scanSameRootAria |
| focus | Focus ownership matches focusModel="none". | lint-plugin & spec-compiler |
| contrast | Renders legible borders, focus outlines, and selection indicators under forced-colors: active. | Playwright forced-colors matrix |
| states | Exposes ElementInternals CustomStateSet flags: :state(pill), :state(dot). | Conformance suite |