Badge
A compact label for a status, a category or a count.
Use a badge to label an item with its status or category, next to its name. A badge isn't interactive; for a filter people can toggle, use a button.
import { Badge } from "@aloxe/react";
export default function BadgeTones() {
return (
<div className="flex flex-wrap items-center gap-2">
<Badge tone="neutral">Draft</Badge>
<Badge tone="accent">Beta</Badge>
<Badge tone="success">Paid</Badge>
<Badge tone="warning">Due in 3 days</Badge>
<Badge tone="danger">Overdue</Badge>
</div>
);
}Installation
npm i @aloxe/react @aloxe/tokensThen add the CSS imports from Installation.
Usage
import { Badge } from "@aloxe/react";
<Badge tone="success">Paid</Badge>Choose the tone by meaning: neutral for labels and counts, accent for brand highlights, success, warning and danger for state. Badge is a server component.
Examples
Solid
Solid badges stand out more. Keep them for the one status that needs attention in a view.
import { Badge } from "@aloxe/react";
export default function BadgeSolid() {
return (
<div className="flex flex-wrap items-center gap-2">
<Badge tone="neutral" variant="solid">Archived</Badge>
<Badge tone="accent" variant="solid">New</Badge>
<Badge tone="success" variant="solid">Live</Badge>
<Badge tone="warning" variant="solid">Degraded</Badge>
<Badge tone="danger" variant="solid">Down</Badge>
</div>
);
}With an icon
A 12 px icon before the label can reinforce the meaning. The text still has to say it on its own.
import { Badge } from "@aloxe/react";
import { CircleCheck, Lock } from "lucide-react";
export default function BadgeWithIcon() {
return (
<div className="flex flex-wrap items-center gap-2">
<Badge tone="success">
<CircleCheck />
Verified
</Badge>
<Badge tone="neutral">
<Lock />
Private
</Badge>
</div>
);
}Accessibility
A badge isn't focusable and has no keyboard interaction.
- The text carries the meaning; colour only reinforces it.
- Text in every tone and style meets 4.5:1 contrast in light and dark.
- If a badge is a count, give it context for screen readers, for example
<Badge>3<span className="sr-only"> unread</span></Badge>.
API reference
Every part accepts className and renders a data-aloxe attribute you can target in CSS, such as [data-aloxe="badge"].
Badge
| Prop | Type | Default | Description |
|---|---|---|---|
| tone | "neutral" | "accent" | "success" | "warning" | "danger" | "neutral" | Colour, chosen by meaning: neutral for labels and counts, accent for the brand, the status tones for state. |
| variant | "subtle" | "solid" | "subtle" | Figma Style. Keep solid for the one badge that must stand out. |
| children | ReactNode | A short label, optionally with a 12 px icon before it. | |
| className | string | Merged with the default classes. Other props go to the <span>. |
Figma
Matches the Badge component. Figma Tone maps to tone and Style (Subtle, Solid) maps to variant. There is one size, 20 px tall.
See Figma for where to get the file and how its names map to code.