{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "button-icon-badge",
  "type": "registry:component",
  "title": "Button Icon Badge",
  "description": "An icon button with a notification badge cut out of the background. New items make the bell swing, the badge pop and a ring ping, and the number rolls in; clicking clears it with a drop.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "buttons",
    "button",
    "icon button",
    "badge",
    "notifications",
    "counter",
    "bell"
  ],
  "docs": "https://hyperblur.dev/effects/button-icon-badge",
  "files": [
    {
      "path": "registry/hyperblur/button-icon-badge.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/button-icon-badge.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface ButtonIconBadgeProps\n  extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, \"children\"> {\n  count?: number;\n  defaultCount?: number;\n  onCountChange?: (count: number) => void;\n  max?: number;\n  dot?: boolean;\n  clearOnClick?: boolean;\n  label?: string;\n  icon?: React.ReactNode;\n  shape?: \"square\" | \"circle\";\n  badgeColor?: string;\n  ringColor?: string;\n  accent?: string;\n}\n\nconst css = `\n.hb-xb9 {\n  --hb-xb9-c: #2f7bff;\n  --hb-xb9-b: #ff3b4e;\n  --hb-xb9-r: #0a0a0a;\n  position: relative;\n  display: inline-grid;\n  place-items: center;\n  box-sizing: border-box;\n  width: 42px;\n  height: 42px;\n  margin: 0;\n  padding: 0;\n  border: 0;\n  border-radius: 12px;\n  color: #d4d4d4;\n  font: inherit;\n  cursor: pointer;\n  background: linear-gradient(180deg, #1c1c1c, #141414);\n  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), inset 0 0 0 1px #2a2a2a, 0 6px 14px -8px rgba(0, 0, 0, 0.9);\n  -webkit-tap-highlight-color: transparent;\n  transition: color 0.2s ease, box-shadow 0.25s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.25s ease;\n}\n.hb-xb9 *, .hb-xb9 *::before, .hb-xb9 *::after { box-sizing: border-box; }\n.hb-xb9[data-shape=\"circle\"] { border-radius: 50%; }\n.hb-xb9:hover:not(:disabled) { color: #fff; background: linear-gradient(180deg, #222, #181818); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.09), inset 0 0 0 1px #363636, 0 8px 18px -8px rgba(0, 0, 0, 0.9); }\n.hb-xb9:active:not(:disabled) { transform: scale(0.92); }\n.hb-xb9:focus-visible { outline: 2px solid var(--hb-xb9-c); outline-offset: 3px; }\n.hb-xb9:disabled { opacity: 0.45; cursor: not-allowed; }\n.hb-xb9-ic { display: grid; place-items: center; transform-origin: 50% 12%; }\n.hb-xb9-ic[data-ring=\"true\"] { animation: hb-xb9-swing 0.9s cubic-bezier(0.36, 0.07, 0.19, 0.97); }\n.hb-xb9-ic svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }\n.hb-xb9-badge {\n  position: absolute;\n  top: -5px;\n  right: -6px;\n  min-width: 19px;\n  height: 19px;\n  padding: 0 5px;\n  display: inline-flex;\n  align-items: center;\n  justify-content: center;\n  border-radius: 999px;\n  font-size: 11px;\n  font-weight: 700;\n  line-height: 1;\n  color: #fff;\n  font-variant-numeric: tabular-nums;\n  letter-spacing: -0.01em;\n  background: linear-gradient(180deg, color-mix(in srgb, var(--hb-xb9-b) 80%, #fff) 0%, var(--hb-xb9-b) 55%, color-mix(in srgb, var(--hb-xb9-b) 85%, #000) 100%);\n  box-shadow: 0 0 0 2.5px var(--hb-xb9-r), 0 4px 10px -2px color-mix(in srgb, var(--hb-xb9-b) 60%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.3);\n  overflow: hidden;\n  transform: scale(1);\n  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease, translate 0.45s cubic-bezier(0.55, 0, 0.3, 1);\n  pointer-events: none;\n}\n.hb-xb9-badge[data-dot=\"true\"] { min-width: 10px; width: 10px; height: 10px; padding: 0; top: 7px; right: 7px; }\n.hb-xb9[data-shape=\"circle\"] .hb-xb9-badge[data-dot=\"true\"] { top: 6px; right: 6px; }\n.hb-xb9-badge[data-hidden=\"true\"] { transform: scale(0); opacity: 0; translate: 0 4px; }\n.hb-xb9-badge[data-bump=\"true\"] { animation: hb-xb9-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }\n.hb-xb9-n { display: inline-block; animation: hb-xb9-roll 0.38s cubic-bezier(0.22, 1, 0.36, 1); }\n.hb-xb9-ping { position: absolute; top: -5px; right: -6px; width: 19px; height: 19px; border-radius: 999px; border: 2px solid var(--hb-xb9-b); opacity: 0; pointer-events: none; }\n.hb-xb9-ping[data-dot=\"true\"] { width: 10px; height: 10px; top: 7px; right: 7px; }\n.hb-xb9-ping[data-on=\"true\"] { animation: hb-xb9-ping 0.9s cubic-bezier(0.22, 1, 0.36, 1); }\n@keyframes hb-xb9-swing { 0% { transform: rotate(0); } 15% { transform: rotate(16deg); } 32% { transform: rotate(-13deg); } 48% { transform: rotate(9deg); } 64% { transform: rotate(-5deg); } 80% { transform: rotate(2deg); } 100% { transform: rotate(0); } }\n@keyframes hb-xb9-pop { 0% { transform: scale(1); } 35% { transform: scale(1.35); } 100% { transform: scale(1); } }\n@keyframes hb-xb9-roll { from { transform: translateY(105%); opacity: 0; } to { transform: none; opacity: 1; } }\n@keyframes hb-xb9-ping { 0% { opacity: 0.85; transform: scale(1); } 100% { opacity: 0; transform: scale(2.1); } }\n@media (prefers-reduced-motion: reduce) {\n  .hb-xb9, .hb-xb9 * { transition-duration: 0.01s !important; animation: none !important; }\n}\n`;\n\nconst bell = (\n  <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n    <path d=\"M6 16.5V11a6 6 0 0 1 12 0v5.5l1.5 2h-15zM10 20.5a2.2 2.2 0 0 0 4 0\" />\n  </svg>\n);\n\nexport function ButtonIconBadge({\n  count,\n  defaultCount = 3,\n  onCountChange,\n  max = 99,\n  dot = false,\n  clearOnClick = true,\n  label = \"Notifications\",\n  icon = bell,\n  shape = \"square\",\n  badgeColor = \"#ff3b4e\",\n  ringColor = \"#0a0a0a\",\n  accent = \"#2f7bff\",\n  disabled = false,\n  type = \"button\",\n  className = \"\",\n  style,\n  onClick,\n  ...rest\n}: ButtonIconBadgeProps) {\n  const [inner, setInner] = React.useState(defaultCount);\n  const value = Math.max(0, count ?? inner);\n  const [seen, setSeen] = React.useState(value);\n  const [bump, setBump] = React.useState(0);\n  if (value !== seen) {\n    if (value > seen) setBump((b) => b + 1);\n    setSeen(value);\n  }\n  const text = value > max ? `${max}+` : String(value);\n  const hidden = value === 0;\n  const [shown, setShown] = React.useState(hidden ? \"1\" : text);\n  if (!hidden && shown !== text) setShown(text);\n\n  return (\n    <button\n      type={type}\n      disabled={disabled}\n      aria-label={hidden ? label : `${label}, ${value} unread`}\n      className={`hb-xb9 ${className}`.trim()}\n      data-shape={shape}\n      style={{ \"--hb-xb9-c\": accent, \"--hb-xb9-b\": badgeColor, \"--hb-xb9-r\": ringColor, ...style } as React.CSSProperties}\n      onClick={(e) => {\n        onClick?.(e);\n        if (e.defaultPrevented || !clearOnClick || value === 0) return;\n        if (count === undefined) setInner(0);\n        onCountChange?.(0);\n      }}\n      {...rest}\n    >\n      <style href=\"hb-button-icon-badge\" precedence=\"default\">{css}</style>\n      <span key={`i${bump}`} className=\"hb-xb9-ic\" data-ring={bump > 0 ? \"true\" : \"false\"} aria-hidden=\"true\">\n        {icon}\n      </span>\n      <span key={`p${bump}`} className=\"hb-xb9-ping\" data-on={bump > 0 && !hidden ? \"true\" : \"false\"} data-dot={dot ? \"true\" : \"false\"} aria-hidden=\"true\" />\n      <span key={`b${bump}`} className=\"hb-xb9-badge\" data-hidden={hidden ? \"true\" : \"false\"} data-dot={dot ? \"true\" : \"false\"} data-bump={bump > 0 ? \"true\" : \"false\"} aria-hidden=\"true\">\n        {!dot && (\n          <span key={shown} className=\"hb-xb9-n\">\n            {shown}\n          </span>\n        )}\n      </span>\n    </button>\n  );\n}\n"
    }
  ]
}