Components
Badge
A short status label with solid, outline, semantic and glass variants.
DefaultSecondaryOutlinePaidPendingFailed
Glass
Use Badge for a short label such as a status, a count or a category. It is not interactive: if it must be clicked, use a Button.
Installation
pnpm dlx shadcn@latest add https://components.abdulqadirmsingi.com/r/badge.json
Usage
import { Badge } from "@/components/ui/badge";
<Badge variant="success">Paid</Badge>Props
Badge extends all native <span> props and spreads them onto the element, including ref (React 19).
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | "default" | "secondary" | "outline" | "success" | "warning" | "danger" | "glass" | "default" | Visual style. |
| className | string | – | Merged with the built-in classes; yours win on conflicts. |
Accessibility
- The text carries the meaning ("Failed", "Paid"). Colour only reinforces it, so it never works alone.
- It is a plain
<span>, so screen readers read it inline. For a status that changes, put it in a live region yourself.
Tokens used
--primary, --primary-foreground, --muted, --foreground, --control-border, --success, --warning, --danger, --background, and the glass variables.
Known limitations
- No dot or icon slot yet; place an inline SVG as a child.
- Glass text contrast has not been measured against worst-case backdrops.
Source
import { cva, type VariantProps } from "class-variance-authority";import type { ComponentProps } from "react";import { cn } from "@/lib/utils";const badgeVariants = cva( "inline-flex items-center gap-1 whitespace-nowrap rounded-full border px-2.5 py-0.5 text-xs font-medium", { variants: { variant: { default: "border-primary bg-primary text-primary-foreground", secondary: "border-transparent bg-muted text-foreground", outline: "border-control-border bg-background text-foreground", success: "border-success bg-background text-success", warning: "border-warning bg-background text-warning", danger: "border-danger bg-background text-danger", glass: "zuri-glass text-foreground", }, }, defaultVariants: { variant: "default" }, },);export interface BadgeProps extends ComponentProps<"span">, VariantProps<typeof badgeVariants> {}/** A short status or label. The text carries the meaning; colour only reinforces it. */export function Badge({ className, variant, ...props }: BadgeProps) { return <span className={cn(badgeVariants({ variant }), className)} {...props} />;}export { badgeVariants };