{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "status-badge",
  "title": "Status Badge",
  "description": "Status chip whose dot squashes against the wall and whose label crossfades as the badge reflows when the status changes.",
  "dependencies": [
    "@radix-ui/react-slot",
    "motion"
  ],
  "devDependencies": [],
  "registryDependencies": [
    "utils",
    "https://reactmotionkit.com/r/motion-kit.json",
    "https://reactmotionkit.com/r/motion-presets.json",
    "https://reactmotionkit.com/r/ball.json",
    "https://reactmotionkit.com/r/use-should-animate.json"
  ],
  "files": [
    {
      "path": "ui/status-badge.tsx",
      "content": "\"use client\"\n\nimport { Slot } from \"@radix-ui/react-slot\"\nimport { animate, AnimatePresence, motion, useMotionValue, useTransform } from \"motion/react\"\nimport {\n  cloneElement,\n  type ComponentProps,\n  type FocusEvent,\n  type KeyboardEvent,\n  type PointerEvent,\n  isValidElement,\n  type ReactElement,\n  type ReactNode,\n  useEffect,\n  useId,\n  useLayoutEffect,\n  useMemo,\n  useRef,\n  useState,\n} from \"react\"\n\nimport { useShouldAnimate } from \"@/hooks/use-should-animate\"\nimport { useBall } from \"@/lib/ball\"\nimport { durations, instant, type Temperament } from \"@/lib/motion\"\nimport { useMotionKit } from \"@/lib/motion-kit\"\nimport { cn } from \"@/lib/utils\"\n\nexport type StatusBadgeTone = \"neutral\" | \"info\" | \"success\" | \"warning\" | \"destructive\" | \"live\"\n\n/*\n * Each tone sets one colour variable; tint, rim, dot and halo are mixed from it. A tone change\n * swaps the variable in one move at the dot's squash (never a CSS colour transition: red to\n * green through oklab passes olive). `--sb-tint` is the background strength (errors sit a\n * touch lighter), `--sb-rim` the outline strength. `info` reads its own `--info` (shipped in\n * the item's cssVars) so it never takes the theme's primary, which may be red or green; the\n * fallback is the same value for themes without it.\n */\nconst tones: Record<StatusBadgeTone, string> = {\n  neutral: \"[--sb-tone:var(--muted-foreground)] [--sb-tint:12%]\",\n  info: \"[--sb-tone:var(--info,oklch(0.55_0.16_252))] [--sb-tint:12%] dark:[--sb-tone:var(--info,oklch(0.72_0.13_252))]\",\n  success: \"[--sb-tone:var(--success)] [--sb-tint:12%]\",\n  warning: \"[--sb-tone:var(--warning)] [--sb-tint:12%]\",\n  destructive: \"[--sb-tone:var(--destructive)] [--sb-tint:10%]\",\n  live: \"[--sb-tone:var(--success)] [--sb-tint:12%]\",\n}\n\nconst sizes = {\n  // `ring`: room for the reduced-motion still ring (3 px past the dot): its left inset matches\n  // the pill's top inset and it keeps 5 px to the label.\n  // The 11 px label's x-height sits half a pixel above the dot's centre: nudge it down to centre.\n  sm: {\n    pill: \"h-5 text-[11px]\",\n    alone: \"size-5\",\n    label: \"translate-y-[0.5px]\",\n    ring: \"-ml-0.5 mr-0.5\",\n  },\n  md: { pill: \"h-[22px] text-xs\", alone: \"size-5\", label: \"\", ring: \"-ml-px mr-0.5\" },\n} as const\n\n/* The dot is the smallest Ball the shape language allows (8 px); an icon marker is 12 px. */\nconst DOT_SIZE = 8\nconst ICON_SIZE = 12\n\n/*\n * One slow breath of a live dot, in seconds: slower than any interaction so it reads as\n * \"running\" in the corner of the eye and never as a call to act.\n */\nconst LIVE_BREATH = 2.4\n/* The live dot swells by a quarter; its halo spreads to 2.2x the dot while fading out. */\nconst BREATH_SCALE = 1.25\nconst HALO_SPREAD = 2.2\n/*\n * The halo is the tone at 45% (the spec's 25% disappeared on the 12% tint in the browser).\n * The breath starts it at 60% and keeps 70% of that (HALO_HOLD) halfway through the spread,\n * so it is still visible once it clears the dot, then fades to nothing.\n */\nconst HALO_START = 0.6\nconst HALO_HOLD = 0.7\n\n/*\n * The kick presses the dot into the wall by `squash x KICK_REACH` of its width: 0.6 px calm\n * (a short press), 2 px lively (a 25% squash, 6 px wide) and 4.4 px playful (capped at 35% by\n * the ball). Below 5x the lively squash stays under 2 px and reads as a colour change only.\n * It reaches the wall in the first 20% of the temperament's duration and stays pressed until\n * 55% (about 140 ms at lively, so the squash is seen), then leaves the wall.\n */\nconst KICK_REACH = 5\nconst KICK_IN = 0.2\nconst KICK_HOLD = 0.55\n\n/*\n * The labels roll (the Roll vocabulary of the shape language, for words): the old one travels\n * one line up while the new one arrives from one line below, over half the temperament's\n * duration, centred on the tone swap. They cross at half opacity a full line apart, so their\n * glyphs never sit on top of each other, and the new label is past 50% at the swap.\n */\nconst LABEL_ROLL = 0.5\n/* A label under 20% opacity no longer reads; the width may only cut what is below it. */\nconst LABEL_VISIBLE = 0.2\n/* Soft edges of the label box: a line leaving dissolves instead of being sliced. */\nconst SOFT_EDGE = \"3px\"\n/* While the box is narrower than a label (mid-reflow), its trailing edge fades over 6 px. */\nconst REFLOW_EDGE = \"6px\"\n\n/*\n * The ripple: on a tone change, a soft ring in the OLD tone leaves the dot and crosses the pill\n * while the new tint takes over, so the eye follows the change from the marker to the label. It\n * is a 256 px ring scaled up from the dot's size (transform only), over 1.5x the change's\n * duration so it is still crossing the label when the kick has settled.\n */\nconst RIPPLE_SIZE = 256\nconst RIPPLE_TIME = 1.5\n/* The ring's centre: the marker's centre (8 px padding + 4 px), the pill's padding without one. */\nconst RIPPLE_AT = 12\n\nconst units: [Intl.RelativeTimeFormatUnit, number][] = [\n  [\"second\", 60],\n  [\"minute\", 60],\n  [\"hour\", 24],\n  [\"day\", Infinity],\n]\n/* \"2 minutes ago\", \"yesterday\": the largest unit that keeps the number under its next step. */\nfunction ago(since: Date | number, now: number) {\n  let value = (new Date(since).getTime() - now) / 1000\n  for (const [unit, next] of units) {\n    if (Math.abs(value) < next) {\n      return new Intl.RelativeTimeFormat(undefined, { numeric: \"auto\" }).format(\n        Math.round(value),\n        unit,\n      )\n    }\n    value /= next\n  }\n  return \"\"\n}\n\n/* The detail card rises 2 px from 96%: a short settle on the badge, not an entrance. */\nconst CARD_CLOSED = { opacity: 0, scale: 0.96, y: 2 }\n\n/*\n * Variants of a rolling label. `custom` carries the timing of the change in progress, so a\n * label that is leaving follows the new change's timeline, not the one it arrived with.\n */\ninterface RollTiming {\n  reduced: boolean\n  delay: number\n  duration: number\n  fade: number\n}\nconst labelRoll = {\n  enter: (t: RollTiming) => (t.reduced ? { opacity: 0.5, y: 0 } : { opacity: 0, y: \"100%\" }),\n  rest: (t: RollTiming) => ({\n    opacity: 1,\n    y: 0,\n    transition: t.reduced\n      ? { duration: t.fade, ease: \"easeOut\" as const }\n      : { duration: t.duration, delay: t.delay, ease: \"linear\" as const },\n  }),\n  leave: (t: RollTiming) =>\n    t.reduced\n      ? { opacity: 0, transition: { duration: 0 } }\n      : {\n          opacity: 0,\n          y: \"-100%\",\n          transition: { duration: t.duration, delay: t.delay, ease: \"linear\" as const },\n        },\n}\n\nexport interface StatusBadgeProps extends Omit<ComponentProps<\"span\">, \"children\"> {\n  /** The label (\"Paid\", \"Pending\"). With `asChild`, the interactive child whose content is the label. */\n  children: ReactNode\n  /** Colour and dot. `live` breathes slowly while on screen. */\n  tone?: StatusBadgeTone\n  /**\n   * Change key: a different value plays the change. Defaults to the tone plus the label text.\n   * Pass it when the label is translated or not plain text.\n   */\n  status?: string\n  /** Height and type size. */\n  size?: \"sm\" | \"md\"\n  /** What sits before the label. */\n  marker?: \"dot\" | \"icon\" | \"none\"\n  /** Icon for `marker=\"icon\"` (12 px). */\n  icon?: ReactNode\n  /** Live breath on the dot. Defaults to true for `live`, false otherwise. */\n  pulse?: boolean\n  /** Shows the dot alone in a 20 px circle; the label stays for screen readers. */\n  labelHidden?: boolean\n  /** Dense tables: the calm kick and label roll whatever the temperament. */\n  dense?: boolean\n  /** Position in a bulk change: the change waits `staggerDelay(index)`, capped at 0.6 s. */\n  index?: number\n  /** Announces each change in a polite live region (\"Status: Paid\"). Off by default. */\n  announce?: boolean\n  /**\n   * Why the status is what it is (\"502 from the payment provider\"). Shown in a small card on\n   * hover, focus and tap, and linked with `aria-describedby`. Makes a plain badge focusable.\n   */\n  detail?: ReactNode\n  /** When the status started. Shown in the detail card as a relative time, current at each opening. */\n  since?: Date | number\n  /** Renders through the child (a button or a link) to make the badge interactive. */\n  asChild?: boolean\n  /** Motion intensity (how much it moves): calm, lively or playful. Wins over `MotionKitProvider`. */\n  temperament?: Temperament\n}\n\ninterface Shown {\n  key: string\n  tone: StatusBadgeTone\n  label: ReactNode\n}\n\nfunction textOf(node: ReactNode): string {\n  if (typeof node === \"string\" || typeof node === \"number\") return String(node)\n  if (Array.isArray(node)) return node.map(textOf).join(\"\")\n  if (isValidElement<{ children?: ReactNode }>(node)) return textOf(node.props.children)\n  return \"\"\n}\n\n/**\n * Status chip for tables and headers. When the status changes, the dot charges toward the\n * label, is kicked into the badge's left wall and squashes there, the label crossfades and the\n * pill reflows to its new width. Live statuses breathe slowly, only while on screen.\n */\nexport function StatusBadge({\n  children,\n  tone = \"neutral\",\n  status,\n  size = \"md\",\n  marker = \"dot\",\n  icon,\n  pulse,\n  labelHidden = false,\n  dense = false,\n  index,\n  announce = false,\n  detail,\n  since,\n  asChild = false,\n  temperament,\n  className,\n  style,\n  ref,\n  onPointerEnter,\n  onPointerLeave,\n  onFocus,\n  onBlur,\n  onKeyDown,\n  ...props\n}: StatusBadgeProps) {\n  const motionKit = useMotionKit(temperament)\n  // A dense table never kicks harder than calm, whatever the page's temperament.\n  const kickMotion = useMotionKit(dense ? \"calm\" : temperament)\n\n  const child = asChild && isValidElement<{ children?: ReactNode }>(children) ? children : null\n  const label = child ? child.props.children : children\n  const key = status ?? `${tone}:${textOf(label)}`\n\n  // What is on screen: it lags the props only while a bulk change waits for its turn.\n  const [shown, setShown] = useState<Shown>({ key, tone, label })\n  const staggered = index !== undefined && index > 0\n  let current = shown\n  if (key !== shown.key && !staggered) {\n    current = { key, tone, label }\n    setShown(current)\n  } else if (key === shown.key) {\n    current = { key, tone, label }\n  }\n  const latest = useRef<Shown>({ key, tone, label })\n  useLayoutEffect(() => {\n    latest.current = { key, tone, label }\n  })\n  useEffect(() => {\n    if (key === shown.key || !staggered) return\n    const timer = setTimeout(\n      () => {\n        setShown(latest.current)\n      },\n      motionKit.staggerDelay(index) * 1000,\n    )\n    return () => {\n      clearTimeout(timer)\n    }\n  }, [key, shown.key, staggered, index, motionKit])\n\n  const markerSize = marker === \"icon\" ? ICON_SIZE : DOT_SIZE\n  const ball = useBall({\n    target: 0,\n    travel: 0,\n    size: markerSize,\n    motion: kickMotion,\n    squashOn: \"stop\",\n  })\n  const { charge, release, raw } = ball\n\n  // The change: charge toward the label, then the kick into the left wall. Errors never bounce.\n  const spoken = textOf(current.label) || current.key\n  // The live region speaks only after a change, never on mount.\n  const [announced, setAnnounced] = useState({ key: current.key, text: \"\" })\n  if (announced.key !== current.key) setAnnounced({ key: current.key, text: `Status: ${spoken}` })\n  // The painted tone swaps in one move: at the squash peak when the dot kicks, halfway through\n  // the label roll when it does not (errors, no marker), at once with reduced motion.\n  const kicks = !motionKit.reduced && current.tone !== \"destructive\" && marker !== \"none\"\n  const anticipation = kickMotion.seconds(kickMotion.values.anticipation)\n  const changeTime = kickMotion.seconds(kickMotion.values.duration)\n  const rollTime = changeTime * LABEL_ROLL\n  const swapAt = kicks ? anticipation + changeTime * KICK_IN : rollTime / 2\n  const timing: RollTiming = {\n    reduced: motionKit.reduced,\n    delay: Math.max(0, swapAt - rollTime / 2),\n    duration: rollTime,\n    fade: motionKit.seconds(durations.fade),\n  }\n  const [paint, setPaint] = useState({ key: current.key, tone: current.tone })\n  if (paint.key === current.key ? paint.tone !== current.tone : motionKit.reduced) {\n    setPaint({ key: current.key, tone: current.tone })\n  }\n  // Read in the effect without making it a dependency: the swap mid-kick must not restart it.\n  const painted = useRef(paint)\n  useLayoutEffect(() => {\n    painted.current = paint\n  })\n  const [ripple, setRipple] = useState<{ key: string; tone: StatusBadgeTone } | null>(null)\n  useEffect(() => {\n    if (painted.current.key === current.key || motionKit.reduced) return\n    const next = { key: current.key, tone: current.tone }\n    const from = painted.current.tone\n    const reach = kickMotion.values.squash * KICK_REACH * markerSize\n    let kick: ReturnType<typeof animate> | undefined\n    const swap = setTimeout(() => {\n      setPaint(next)\n      if (from !== next.tone) setRipple({ key: next.key, tone: from })\n    }, swapAt * 1000)\n    let charged: ReturnType<typeof setTimeout> | undefined\n    if (kicks) {\n      charge(1)\n      charged = setTimeout(() => {\n        release()\n        kick = animate(raw, [0, -reach, -reach, 0], {\n          duration: changeTime,\n          times: [0, KICK_IN, KICK_HOLD, 1],\n          ease: [\"easeOut\", \"linear\", \"easeOut\"],\n        })\n      }, anticipation * 1000)\n    }\n    return () => {\n      clearTimeout(swap)\n      if (charged) clearTimeout(charged)\n      kick?.stop()\n      raw.set(0)\n      setPaint(next)\n    }\n  }, [\n    current.key,\n    current.tone,\n    kicks,\n    motionKit.reduced,\n    swapAt,\n    anticipation,\n    changeTime,\n    markerSize,\n    kickMotion,\n    charge,\n    release,\n    raw,\n  ])\n\n  // Width reflow: the label box springs to the entering label's width.\n  const width = useMotionValue<number | string>(\"auto\")\n  const labelRef = useRef<HTMLSpanElement | null>(null)\n  const widthTarget = useRef<number | null>(null)\n  // The widest label in the box during a change: until the box reaches it, the edge fades.\n  const widest = useRef(0)\n  const reflowMask = useTransform(width, (value) => {\n    const vertical = `linear-gradient(to bottom, transparent, #000 ${SOFT_EDGE}, #000 calc(100% - ${SOFT_EDGE}), transparent)`\n    const cut = typeof value === \"number\" && value < widest.current - 0.5\n    return cut\n      ? `${vertical}, linear-gradient(to right, #000 calc(100% - ${REFLOW_EDGE}), transparent)`\n      : vertical\n  })\n  /*\n   * The width works around the roll so no label is ever sliced: growing, the pill is at the\n   * new width by the time the new label reaches 20% (a quick ease-out from the change);\n   * shrinking, it waits until the old label is under 20%, then settles on the calm spring\n   * (never a bounce: a pill that springs narrower than its label would cut it). With reduced\n   * motion the width changes with the label, at once.\n   */\n  const growTime = timing.delay + timing.duration * LABEL_VISIBLE\n  const shrinkAt = timing.delay + timing.duration * (1 - LABEL_VISIBLE)\n  const reflowGrow = useMemo(\n    () => (motionKit.reduced ? instant : { duration: growTime, ease: \"easeOut\" as const }),\n    [motionKit.reduced, growTime],\n  )\n  const reflowShrink = useMemo(\n    () => (motionKit.reduced ? instant : { ...motionKit.springCalm, delay: shrinkAt }),\n    [motionKit.reduced, motionKit.springCalm, shrinkAt],\n  )\n  useLayoutEffect(() => {\n    const node = labelRef.current\n    if (!node) return\n    const next = node.offsetWidth\n    if (widthTarget.current === null) {\n      widest.current = next\n      width.set(next)\n    } else if (next !== widthTarget.current) {\n      widest.current = Math.max(next, widthTarget.current)\n      animate(width, next, {\n        ...(next > widthTarget.current ? reflowGrow : reflowShrink),\n        onComplete: () => {\n          widest.current = next\n          width.set(next)\n        },\n      })\n    }\n    widthTarget.current = next\n  }, [current.key, width, reflowGrow, reflowShrink])\n  useEffect(() => {\n    const node = labelRef.current\n    if (!node || typeof ResizeObserver === \"undefined\") return\n    // Late web fonts change the label's width: follow it without animating.\n    const observer = new ResizeObserver(() => {\n      const next = node.offsetWidth\n      if (next === widthTarget.current || width.isAnimating()) return\n      widthTarget.current = next\n      widest.current = next\n      width.set(next)\n    })\n    observer.observe(node)\n    return () => {\n      observer.disconnect()\n    }\n  }, [current.key, width])\n\n  // Live breath: only on screen, in a visible tab, without reduced motion.\n  const dotRef = useRef<HTMLSpanElement | null>(null)\n  const breathing = (pulse ?? paint.tone === \"live\") && marker !== \"none\"\n  const { shouldAnimate } = useShouldAnimate(dotRef)\n  const breathe = breathing && shouldAnimate\n  const breathDuration = motionKit.seconds(LIVE_BREATH)\n\n  // Reduced motion: a still ring around the live dot; the marker makes room for it so the ring\n  // keeps the pill's top inset on its left and 4 px or more to the label.\n  const stillRing = breathing && motionKit.reduced\n\n  const interactive = child !== null\n\n  // The detail card: open on hover, focus and tap (focus), closed on leave, blur and Escape. The\n  // clock is read each time it opens (never in render), so the relative time is always current.\n  const detailId = useId()\n  const described = detail !== undefined || since !== undefined\n  const [open, setOpen] = useState(false)\n  const [now, setNow] = useState<number | null>(null)\n  const show = (value: boolean) => {\n    if (value) setNow(Date.now())\n    setOpen(value)\n  }\n  // Kept inside the viewport with an 8 px gutter: a badge at a row's end must not push it off.\n  const cardRef = useRef<HTMLSpanElement | null>(null)\n  const [shift, setShift] = useState(0)\n  useLayoutEffect(() => {\n    const node = cardRef.current\n    if (!open || !node) return\n    const box = node.getBoundingClientRect()\n    const room = document.documentElement.clientWidth - 8\n    // The box already carries the last shift: take it out, then keep it inside the gutter.\n    setShift((last) => {\n      const left = box.left - last\n      const right = box.right - last\n      return left < 8 ? 8 - left : right > room ? room - right : 0\n    })\n  }, [open])\n\n  const rippleNode = ripple && (\n    <span\n      aria-hidden\n      className=\"pointer-events-none absolute inset-0 overflow-hidden rounded-[inherit]\"\n    >\n      <motion.span\n        key={ripple.key}\n        className={cn(\n          \"absolute top-1/2 rounded-full bg-[radial-gradient(circle,transparent_45%,color-mix(in_oklab,var(--sb-tone)_45%,transparent)_62%,transparent_70%)]\",\n          tones[ripple.tone],\n        )}\n        style={{\n          width: RIPPLE_SIZE,\n          height: RIPPLE_SIZE,\n          left: labelHidden ? \"50%\" : marker === \"none\" ? 8 : RIPPLE_AT,\n          marginLeft: -RIPPLE_SIZE / 2,\n          marginTop: -RIPPLE_SIZE / 2,\n        }}\n        initial={{ scale: DOT_SIZE / RIPPLE_SIZE, opacity: 1 }}\n        animate={{ scale: 1, opacity: 0 }}\n        transition={{ duration: changeTime * RIPPLE_TIME, ease: \"easeOut\" }}\n        onAnimationComplete={() => {\n          setRipple(null)\n        }}\n      />\n    </span>\n  )\n\n  const sinceText = since !== undefined && now !== null ? ago(since, now) : \"\"\n  const detailNode = described && (\n    // aria-hidden keeps the card out of a button's name; the description is a hidden twin.\n    <motion.span\n      aria-hidden\n      data-slot=\"status-badge-detail\"\n      className={cn(\n        \"absolute bottom-full left-1/2 z-50 -translate-x-1/2 pb-1.5 text-left font-normal whitespace-normal\",\n        !open && \"pointer-events-none\",\n      )}\n      style={{ x: shift, originY: 1 }}\n      initial={false}\n      animate={open ? { opacity: 1, scale: 1, y: 0 } : CARD_CLOSED}\n      transition={motionKit.reduced ? motionKit.fade : motionKit.springSmall}\n    >\n      <span\n        ref={cardRef}\n        className=\"block w-max max-w-64 rounded-xl border bg-popover px-2.5 py-1.5 text-xs text-popover-foreground shadow-[0_8px_24px_-8px_color-mix(in_oklab,var(--sb-tone)_40%,rgb(0_0_0/0.3))]\"\n      >\n        <span className=\"flex items-center gap-1.5 font-medium\">\n          <span className=\"size-1.5 shrink-0 rounded-full bg-[var(--sb-tone)]\" />\n          <span>\n            {spoken}\n            {sinceText && <span className=\"font-normal text-muted-foreground\"> · {sinceText}</span>}\n          </span>\n        </span>\n        {detail !== undefined && (\n          <span className=\"mt-0.5 block text-muted-foreground\">{detail}</span>\n        )}\n      </span>\n    </motion.span>\n  )\n\n  const markerNode =\n    marker === \"none\" ? null : (\n      <span\n        ref={dotRef}\n        aria-hidden\n        data-slot=\"status-badge-marker\"\n        className={cn(\n          \"relative inline-flex shrink-0 items-center justify-center\",\n          stillRing && sizes[size].ring,\n        )}\n        style={{ width: markerSize, height: markerSize }}\n      >\n        {breathing && !motionKit.reduced && (\n          <motion.span\n            className=\"absolute inset-0 rounded-full bg-[color-mix(in_oklab,var(--sb-tone)_45%,transparent)]\"\n            initial={false}\n            animate={\n              breathe\n                ? { scale: [1, HALO_SPREAD], opacity: [HALO_START, HALO_START * HALO_HOLD, 0] }\n                : { scale: 1, opacity: 0 }\n            }\n            transition={\n              breathe\n                ? { duration: breathDuration, repeat: Infinity, ease: \"easeOut\" }\n                : motionKit.fade\n            }\n          />\n        )}\n        {stillRing && (\n          // Still halo for reduced motion: a 2 px ring 1 px off the dot, the tone darkened\n          // toward the foreground so it holds 3:1 on the tint and \"live\" never reads as \"success\".\n          <span className=\"absolute -inset-[3px] rounded-full border-2 border-[color-mix(in_oklab,var(--sb-tone)_75%,var(--foreground))]\" />\n        )}\n        <motion.span\n          className=\"absolute inset-0\"\n          initial={false}\n          animate={breathe ? { scale: [1, BREATH_SCALE, 1] } : { scale: 1 }}\n          transition={\n            breathe\n              ? { duration: breathDuration, repeat: Infinity, ease: \"easeInOut\" }\n              : motionKit.fade\n          }\n        >\n          {/* Wall squash: flattens against the badge's left wall on a status change. */}\n          <motion.span\n            className=\"absolute inset-0\"\n            style={{ scaleX: ball.wallAlong, scaleY: ball.wallAcross, originX: 0 }}\n          >\n            {/* Charge stretch: leans toward the label before the kick. */}\n            <motion.span\n              className={cn(\n                \"absolute inset-0 flex items-center justify-center rounded-full\",\n                marker === \"dot\"\n                  ? \"bg-[var(--sb-tone)] shadow-[0_0_0_1px_color-mix(in_oklab,var(--sb-tone)_60%,var(--foreground))]\"\n                  : \"text-[color-mix(in_oklab,var(--sb-tone)_75%,var(--foreground))] [&_svg]:size-3\",\n              )}\n              style={{ originX: ball.anchor }}\n              initial={false}\n              animate={{ scaleX: ball.chargePose.along, scaleY: ball.chargePose.across }}\n              transition={kickMotion.springSmall}\n            >\n              {marker === \"icon\" ? icon : null}\n            </motion.span>\n          </motion.span>\n        </motion.span>\n      </span>\n    )\n\n  const labelNode = labelHidden ? (\n    <span className=\"sr-only\">{current.label}</span>\n  ) : (\n    <motion.span\n      data-slot=\"status-badge-label\"\n      className={cn(\"relative inline-flex h-full items-center overflow-hidden\", sizes[size].label)}\n      style={{ width, maskImage: reflowMask, WebkitMaskImage: reflowMask }}\n    >\n      <AnimatePresence mode=\"popLayout\" initial={false} custom={timing}>\n        <motion.span\n          key={current.key}\n          ref={labelRef}\n          className=\"inline-block whitespace-nowrap\"\n          custom={timing}\n          variants={labelRoll}\n          initial=\"enter\"\n          animate=\"rest\"\n          exit=\"leave\"\n        >\n          {current.label}\n        </motion.span>\n      </AnimatePresence>\n    </motion.span>\n  )\n\n  const content = (\n    <>\n      {rippleNode}\n      {markerNode}\n      {labelNode}\n      {detailNode}\n    </>\n  )\n\n  const rootProps = {\n    ref,\n    \"data-slot\": \"status-badge\",\n    \"data-tone\": current.tone,\n    \"data-paint\": paint.tone,\n    className: cn(\n      \"relative inline-flex shrink-0 items-center gap-1.5 rounded-full align-middle font-medium text-foreground\",\n      \"bg-[color-mix(in_oklab,var(--sb-tone)_var(--sb-tint),transparent)] [--sb-rim:25%]\",\n      \"shadow-[0_0_0_1px_color-mix(in_oklab,var(--sb-tone)_var(--sb-rim),transparent),inset_0_1px_0_0_rgb(255_255_255/0.5)] dark:shadow-[0_0_0_1px_color-mix(in_oklab,var(--sb-tone)_var(--sb-rim),transparent),inset_0_1px_0_0_rgb(255_255_255/0.06)]\",\n      \"transition-[translate]\",\n      tones[paint.tone],\n      labelHidden ? cn(sizes[size].alone, \"justify-center\") : cn(sizes[size].pill, \"px-2\"),\n      interactive &&\n        // Hover and press deepen the tint; the pill sinks a pixel while pressed. The pseudo\n        // element keeps a 24 px hit area on the 20-22 px pill.\n        \"cursor-pointer outline-none select-none before:absolute before:inset-x-0 before:top-1/2 before:h-6 before:-translate-y-1/2 before:content-[''] hover:[--sb-rim:40%] hover:[--sb-tint:18%] focus-visible:ring-[3px] focus-visible:ring-ring/50 active:translate-y-px active:[--sb-rim:40%] active:[--sb-tint:18%]\",\n      described &&\n        !interactive &&\n        \"outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50\",\n      className,\n    ),\n    style,\n    ...(described && {\n      \"aria-describedby\": detailId,\n      tabIndex: interactive ? undefined : 0,\n    }),\n    onPointerEnter: (event: PointerEvent<HTMLSpanElement>) => {\n      onPointerEnter?.(event)\n      if (described && event.pointerType !== \"touch\") show(true)\n    },\n    onPointerLeave: (event: PointerEvent<HTMLSpanElement>) => {\n      onPointerLeave?.(event)\n      if (event.pointerType !== \"touch\") setOpen(false)\n    },\n    onFocus: (event: FocusEvent<HTMLSpanElement>) => {\n      onFocus?.(event)\n      if (described) show(true)\n    },\n    onBlur: (event: FocusEvent<HTMLSpanElement>) => {\n      onBlur?.(event)\n      setOpen(false)\n    },\n    onKeyDown: (event: KeyboardEvent<HTMLSpanElement>) => {\n      onKeyDown?.(event)\n      if (event.key === \"Escape\" && open) setOpen(false)\n    },\n    ...props,\n  }\n\n  return (\n    <>\n      {child ? (\n        <Slot {...rootProps}>\n          {cloneElement(child as ReactElement<{ children?: ReactNode }>, undefined, content)}\n        </Slot>\n      ) : (\n        <span {...rootProps}>{content}</span>\n      )}\n      {described && (\n        <span id={detailId} hidden>\n          {sinceText && `${sinceText}. `}\n          {detail}\n        </span>\n      )}\n      {announce && (\n        <span role=\"status\" className=\"sr-only\">\n          {announced.text}\n        </span>\n      )}\n    </>\n  )\n}\n",
      "type": "registry:ui"
    }
  ],
  "cssVars": {
    "theme": {
      "color-success": "var(--success)",
      "color-warning": "var(--warning)",
      "color-info": "var(--info)"
    },
    "light": {
      "success": "oklch(0.56 0.14 155)",
      "warning": "oklch(0.7 0.15 70)",
      "info": "oklch(0.55 0.16 252)"
    },
    "dark": {
      "success": "oklch(0.72 0.15 155)",
      "warning": "oklch(0.8 0.14 75)",
      "info": "oklch(0.72 0.13 252)"
    }
  },
  "meta": {
    "tier": "free",
    "collection": "interface",
    "needsImage": false,
    "addedAt": "2026-10-18",
    "tags": [
      "status",
      "badge",
      "chip",
      "table",
      "dashboard",
      "live",
      "data",
      "tooltip"
    ],
    "triggers": [
      "value",
      "ambient"
    ],
    "wave": "2",
    "tech": [],
    "presets": [],
    "keyboard": [
      {
        "keys": "Tab",
        "action": "With detail or since: focuses the badge and opens its detail card"
      },
      {
        "keys": "Escape",
        "action": "Closes the detail card"
      }
    ],
    "reducedMotion": "No stretch, squash or ripple: the tone swaps at once and the labels cross-fade in the short fade time; live dots keep a still 2 px ring so live never reads as success.",
    "heavy": false,
    "ai": {
      "summary": "Status chip that animates when the status changes, with detail on hover",
      "useCases": [
        "Invoice paid, pending or overdue in a table",
        "Job running, queued or failed in a list row",
        "Sync status in a page header with the failure reason",
        "Clickable status filter using asChild"
      ],
      "whenToUse": "Use it to show the state of a record. The dot squashes and the label rolls when the status changes, and detail and since show the reason on hover, focus or tap.",
      "whenNotToUse": "For counts use a number badge. For a choice the person makes use `segmented-control` or `combobox`.",
      "pairsWith": [
        "data-table",
        "description-list",
        "kanban-board",
        "avatar-group"
      ],
      "contexts": [
        "dashboard",
        "saas-app",
        "data"
      ],
      "keywords": [
        "status",
        "badge",
        "chip",
        "pill",
        "tag",
        "state",
        "label",
        "live indicator",
        "tone",
        "invoice status"
      ],
      "triggers": [
        "value",
        "hover",
        "focus",
        "ambient"
      ]
    }
  },
  "categories": [
    "data"
  ],
  "type": "registry:ui"
}