Badge
A non-interactive status label. Each variant maps to a status token pair (--success/--success-bg and so on), so colour carries meaning rather than decoration. Rendering a status the data does not have is a content error, not a styling choice.
rounded-full is the one sanctioned pill in this system. Antislop R-11 bans pill controls but keeps pills for badges because colour and shape together encode real status (R-09).
Interactive Preview
Section titled “Interactive Preview”import { Badge } from "@/components/ui/badge";
<Badge status="success">Active</Badge><Badge status="warning">Pending</Badge><Badge status="neutral">Unset</Badge><script lang="ts"> import Badge from "@/components/ui/badge.svelte";</script>
<Badge status="success">Active</Badge><Badge status="warning">Pending</Badge><Badge status="neutral">Unset</Badge>import { Badge } from "@/components/ui/badge";
<Badge status="success">Active</Badge><Badge status="warning">Pending</Badge><Badge status="neutral">Unset</Badge>Installation
Section titled “Installation”npx @glaceon/cli add badge --framework react # or svelte, solidBadge is CSS-only. No Zag machine is needed.
bun add clsx tailwind-mergeThen copy the source for your framework:
import type { HTMLAttributes } from "react"import { cn } from "@/lib/cn"
export type BadgeStatus = "success" | "warning" | "accent" | "danger" | "info" | "purple" | "neutral" | "pending"
export interface BadgeProps extends HTMLAttributes<HTMLSpanElement> { status?: BadgeStatus}
const base = "inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-bold whitespace-nowrap"
const statuses: Record<BadgeStatus, string> = { success: "bg-success-bg text-success", warning: "bg-warning-bg text-warning", accent: "bg-accent-bg text-accent", danger: "bg-danger-bg text-danger", info: "bg-info-bg text-info", purple: "bg-purple-bg text-purple", neutral: "bg-neutral-bg text-neutral", pending: "bg-pending-bg text-pending",}
export function Badge({ status = "neutral", className, ...props }: BadgeProps) { return <span {...props} className={cn(base, statuses[status], className)} />}<script lang="ts"> import type { Snippet } from "svelte" import { cn } from "@/lib/cn"
type Status = "success" | "warning" | "accent" | "danger" | "info" | "purple" | "neutral" | "pending"
interface Props { status?: Status class?: string children?: Snippet }
const { status = "neutral", class: className, children, ...rest }: Props = $props()
const base = "inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-bold whitespace-nowrap"
const statuses: Record<Status, string> = { success: "bg-success-bg text-success", warning: "bg-warning-bg text-warning", accent: "bg-accent-bg text-accent", danger: "bg-danger-bg text-danger", info: "bg-info-bg text-info", purple: "bg-purple-bg text-purple", neutral: "bg-neutral-bg text-neutral", pending: "bg-pending-bg text-pending", }</script>
<span {...rest} class={cn(base, statuses[status], className)}> {@render children?.()}</span>import { splitProps, type JSX } from "solid-js"import { cn } from "@/lib/cn"
export type BadgeStatus = "success" | "warning" | "accent" | "danger" | "info" | "purple" | "neutral" | "pending"
export interface BadgeProps extends JSX.HTMLAttributes<HTMLSpanElement> { status?: BadgeStatus}
const base = "inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-bold whitespace-nowrap"
const statuses: Record<BadgeStatus, string> = { success: "bg-success-bg text-success", warning: "bg-warning-bg text-warning", accent: "bg-accent-bg text-accent", danger: "bg-danger-bg text-danger", info: "bg-info-bg text-info", purple: "bg-purple-bg text-purple", neutral: "bg-neutral-bg text-neutral", pending: "bg-pending-bg text-pending",}
export function Badge(props: BadgeProps) { const [local, rest] = splitProps(props, ["status", "class"]) return <span {...rest} class={cn(base, statuses[local.status ?? "neutral"], local.class)} />}Variants
Section titled “Variants”| Variant | Tokens | Meaning |
|---|---|---|
success |
--success / --success-bg |
Positive or completed state. |
warning |
--warning / --warning-bg |
Needs attention. |
accent |
--accent / --accent-bg |
In progress or highlighted. |
danger |
--danger / --danger-bg |
Failure or destructive. |
info |
--info / --info-bg |
Informational or neutral message. |
purple |
--purple / --purple-bg |
Secondary or categorical. |
neutral |
--neutral / --neutral-bg |
Neutral or unset. |
pending |
--pending / --pending-bg |
Pending review. |
API Reference (Props)
Section titled “API Reference (Props)”| Prop | Type | Default | Description |
|---|---|---|---|
status |
"success" | "warning" | "accent" | "danger" | "info" | "purple" | "neutral" | "pending" |
"neutral" |
Selects the token pair. |
class / className |
string |
undefined |
Extra classes, appended last. |
Accessibility
Section titled “Accessibility”Colour alone does not carry the status: every badge contains text, so the meaning survives greyscale, colour-blindness, and screen readers.
The label renders at 12px (normal text), so the required contrast ratio is 4.5:1. All variants pass. The four that previously failed had their foreground token darkened in @glaceon/tokens.
| Variant | Ratio | AA (4.5:1) |
|---|---|---|
success |
5.39:1 | pass |
warning |
5.21:1 | pass |
accent |
5.31:1 | pass |
danger |
5.10:1 | pass |
info |
4.67:1 | pass |
purple |
5.03:1 | pass |
neutral |
6.50:1 | pass |
pending |
6.69:1 | pass |