Documentation / Display & media
Badge
A compact label to qualify an item: a status, a category, a counter. Nine semantic or decorative colours, four variants (soft by default, solid, outlined, subtle) and three sizes.
The badge can carry a dot (dot) or an icon (icon) before the text — the dot wins if both are given. It is pill-shaped by default (pill={false} for square corners). A hook-free component: it renders on the server.
Examples
Basic usage
The text goes in as children; color gives the meaning.
import { Badge } from "@synertech/ui";
export function Basic() {
return (
<div className="flex flex-wrap gap-2">
<Badge>Brouillon</Badge>
<Badge color="primary">Nouveau</Badge>
<Badge color="success">Actif</Badge>
<Badge color="warning">En attente</Badge>
<Badge color="error">Rejeté</Badge>
</div>
);
}Variants
From the strongest to the most discreet: solid, soft, outlined, subtle.
import { Badge } from "@synertech/ui";
export function Variants() {
return (
<div className="flex flex-wrap gap-2">
<Badge color="indigo" variant="solid">
Solid
</Badge>
<Badge color="indigo" variant="soft">
Soft
</Badge>
<Badge color="indigo" variant="outlined">
Outlined
</Badge>
<Badge color="indigo" variant="subtle">
Subtle
</Badge>
</div>
);
}Sizes and shape
size sets the padding and the type size; pill={false} swaps the pill for square corners.
import { Badge } from "@synertech/ui";
export function SizesAndShape() {
return (
<div className="flex flex-wrap items-center gap-2">
<Badge size="sm" color="teal">
Petit
</Badge>
<Badge size="md" color="teal">
Moyen
</Badge>
<Badge size="lg" color="teal">
Grand
</Badge>
<Badge size="md" color="teal" pill={false}>
Coins droits
</Badge>
</div>
);
}Dot and icon
dot adds a dot in the badge’s colour; icon places an icon before the text.
import { Badge } from "@synertech/ui";
const CheckIcon = () => (
<svg fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2} aria-hidden="true">
<path strokeLinecap="round" strokeLinejoin="round" d="M5 13l4 4L19 7" />
</svg>
);
export function DotAndIcon() {
return (
<div className="flex flex-wrap gap-2">
<Badge color="success" dot>
En ligne
</Badge>
<Badge color="default" dot>
Hors ligne
</Badge>
<Badge color="primary" icon={<CheckIcon />}>
Vérifié
</Badge>
</div>
);
}Statuses in a list
A common case: the status of each row of an orders table.
import { Badge, type BadgeColor } from "@synertech/ui";
const orders: { id: string; status: string; color: BadgeColor }[] = [
{ id: "CMD-1042", status: "Livrée", color: "success" },
{ id: "CMD-1043", status: "En préparation", color: "warning" },
{ id: "CMD-1044", status: "Annulée", color: "error" },
{ id: "CMD-1045", status: "Expédiée", color: "info" },
];
export function OrderStatuses() {
return (
<ul className="divide-y divide-gray-200 rounded-lg border border-gray-200 dark:divide-gray-700 dark:border-gray-700">
{orders.map((order) => (
<li key={order.id} className="flex items-center justify-between px-4 py-2 text-sm">
<span className="font-mono text-gray-700 dark:text-gray-300">{order.id}</span>
<Badge color={order.color} dot>
{order.status}
</Badge>
</li>
))}
</ul>
);
}API reference
Components
import { Badge } from "@synertech/ui";Props — BadgeProps
| Prop | Type | Default | Description |
|---|---|---|---|
children |
ReactNode |
— | |
color |
BadgeColor |
"default" |
|
dot |
boolean |
false |
|
icon |
ReactNode |
— | |
pill |
boolean |
true |
|
size |
BadgeSize |
"md" |
|
variant |
BadgeVariant |
"soft" |
+ 277 inherited native attributes from HTMLAttributes, AriaAttributes, DOMAttributes (className, id, aria-*, event handlers…).
Types
BadgeColor
Typetype BadgeColor = | "default"
| "primary"
| "success"
| "warning"
| "error"
| "info"
| "purple"
| "indigo"
| "teal"BadgeSize
Typetype BadgeSize = "sm" | "md" | "lg"BadgeVariant
Typetype BadgeVariant = "solid" | "soft" | "outlined" | "subtle"