Badge
A small status or label badge with color variants, dot indicator, and removal.
Rendering Badge…
Installation
Copy the source into your project with the CLI. It lands under @/components/ui and is yours to edit.
npx mlola-ui add badgeUsage
import { Badge } from "@/components/ui/badge";
export default function Example() {
return (
<div className="ml-cluster">
<Badge>Draft</Badge>
<Badge tone="success" dot>Live</Badge>
<Badge tone="warning" variant="outline">Review</Badge>
<Badge tone="danger" variant="solid">Failed</Badge>
</div>
);
}Styling comes from the engine stylesheet and the nearest theme. Set it once at the root:
<html data-theme="graphite" data-mode="light">HTML
The markup the example above renders, exactly. It needs no script: write it from any language or template.
<div class="ml-cluster">
<span class="ml-badge" data-tone="neutral" data-variant="soft" data-size="md"><span class="ml-badge-label">Draft</span></span>
<span class="ml-badge" data-tone="success" data-variant="soft" data-size="md"><span class="ml-badge-dot" aria-hidden="true"></span><span class="ml-badge-label">Live</span></span>
<span class="ml-badge" data-tone="warning" data-variant="outline" data-size="md"><span class="ml-badge-label">Review</span></span>
<span class="ml-badge" data-tone="danger" data-variant="solid" data-size="md"><span class="ml-badge-label">Failed</span></span>
</div>Options
| Prop | Values | Default |
|---|---|---|
size | smmdlg | md |
tone | neutralprimaryinfosuccesswarningdanger | neutral |
variant | softsolidoutline | soft |
Every prop with a fixed set of values, read from the exported TypeScript types with its doc comment. Open the Code tab above for the rest of the API.
Classes and attributes
A class names each element; data-* and aria-* attributes carry its variant and state. The values listed are the ones the stylesheet draws; the default needs no attribute.
| Class | Attributes |
|---|---|
ml-badge | data-size="lg | sm"data-tone="danger | info | primary | success | warning"data-variant="outline | solid" |
ml-badge-label | — |
ml-badge-dot | — |
ml-badge-remove | — |
Accessibility and theming
- Semantic elements, accessible names and state relationships are part of the contract.
- Keyboard, pointer and touch paths are operable; focus stays visible in every theme.
- Light and dark modes pass WCAG AA contrast in all 5 canonical themes.
- Reduced motion and forced colors keep meaning and operation.
Dependencies
Installed alongside this component. No third-party UI runtime is ever added.
@mlola-ui/icons