Examples
Semantic states
Readable words carry the meaning alongside semantic color roles.
Badge examples for neutral and semantic states
import { Badge } from "@phuctech/ui/components/badge";
export function Example() {
return <Badge variant="success">Operational</Badge>;
}
Color palettes
Use a supported hue for neutral Badge treatments without reaching for raw color values.
Badge color palette comparison
import { Badge } from "@phuctech/ui/components/badge";
import {
colorPaletteLabels,
colorPalettes,
type ColorPalette,
} from "@phuctech/ui/color-palette";
const palettes = colorPalettes.filter((palette): palette is Exclude<ColorPalette, "neutral"> => palette !== "neutral");
export function Example() {
return (
<div className="flex flex-wrap items-center justify-center gap-2">
{palettes.map((palette) => (
<Badge key={palette} colorPalette={palette}>
{colorPaletteLabels[palette]}
</Badge>
))}
</div>
);
}
Density
Small, default, and large labels align with nearby content.
Badge size comparison
import { Badge } from "@phuctech/ui/components/badge";
export function Example() {
return <Badge variant="success">Operational</Badge>;
}Status with a clear label
Never use a color-only dot when a state affects understanding.
Badge status with readable text
import { Badge } from "@phuctech/ui/components/badge";
export function Example() {
return <Badge variant="success">Operational</Badge>;
}In a list or Card
Badge adds metadata without turning the surrounding surface into a control; use the playground to compare hue and treatment.
A status label in a compact list row.
Badge inside a list row
import { Badge } from "@phuctech/ui/components/badge";
export function Example() {
return <Badge variant="default" colorPalette="violet">Active</Badge>;
}When to use
Use Badge for a short label such as a lifecycle state, role, or queue. Use body text or an Alert when people need an explanation, next step, or announcement.
Usage
import { Badge } from "@phuctech/ui/components/badge";
export function Example() {
return <Badge variant="success">Operational</Badge>;
}
Variants
API
Tokens
Accessibility
- Write the state in the label: “Operational” is better than a green dot alone.
- Use sufficient contrast for the label and boundary in both themes.
- Do not make Badge interactive; use Button or a link when it needs activation.
Do and don’t
Keep the label short, readable, and redundant with the color meaning.
Put paragraphs, controls, or the only error explanation inside a Badge.