Status badge

A small pill for states such as live, paused, failed or draft. Five tones, an optional pulsing dot, and theme colours so it fits light and dark mode.

Tables & dataComponentTailwind v4

Source

import { clsx } from "clsx";

type Tone = "neutral" | "success" | "warning" | "danger" | "info";

const tones: Record<Tone, string> = {
  neutral: "bg-muted text-muted-foreground",
  success: "bg-emerald-500/12 text-emerald-700 dark:text-emerald-300",
  warning: "bg-amber-500/15 text-amber-700 dark:text-amber-300",
  danger: "bg-destructive/12 text-destructive",
  info: "bg-sky-500/12 text-sky-700 dark:text-sky-300",
};

export function StatusBadge({ tone = "neutral", pulse = false, children }: { tone?: Tone; pulse?: boolean; children: React.ReactNode }) {
  return (
    <span className={clsx("inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium", tones[tone])}>
      <span className="relative flex size-1.5">
        {pulse && <span className="absolute inline-flex size-full animate-ping rounded-full bg-current opacity-60" />}
        <span className="relative inline-flex size-1.5 rounded-full bg-current" />
      </span>
      {children}
    </span>
  );
}