{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "button-badge",
"type": "registry:ui",
"title": "Button Badge",
"description": "iOS 26 liquid-glass pill with floating spring-animated notification badge.",
"dependencies": [
"motion"
],
"files": [
{
"path": "registry/ruixenui/button-badge.tsx",
"content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion, AnimatePresence } from \"motion/react\";\n\n/* ── sound ── */\nlet _a: AudioContext, _b: AudioBuffer;\nconst tick = () => {\n if (typeof window === \"undefined\") return;\n if (!_a) {\n _a = new AudioContext();\n _b = _a.createBuffer(1, (_a.sampleRate * 0.003) | 0, _a.sampleRate);\n const d = _b.getChannelData(0);\n for (let i = 0; i < d.length; i++)\n d[i] = (Math.random() * 2 - 1) * (1 - i / d.length) ** 4;\n }\n const s = _a.createBufferSource();\n s.buffer = _b;\n const g = _a.createGain();\n g.gain.value = 0.08;\n s.connect(g).connect(_a.destination);\n s.start();\n};\n\n/* ── theme ── */\nconst CSS = `\n.bb{\n --bb-glass:linear-gradient(180deg,rgba(255,255,255,0.78),rgba(255,255,255,0.62));\n --bb-border:rgba(0,0,0,0.06);\n --bb-shadow:0 0 1px rgba(0,0,0,0.04),0 2px 8px rgba(0,0,0,0.04),inset 0 1px 0 rgba(255,255,255,0.8);\n --bb-hi:rgba(0,0,0,0.88);\n --bb-badge:#FF3B30;\n --bb-badge-t:#fff\n}\n.dark .bb,[data-theme=\"dark\"] .bb{\n --bb-glass:linear-gradient(180deg,rgba(255,255,255,0.05),rgba(255,255,255,0.02));\n --bb-border:rgba(255,255,255,0.07);\n --bb-shadow:0 1px 3px rgba(0,0,0,0.08),inset 0 1px 0 rgba(255,255,255,0.04);\n --bb-hi:rgba(255,255,255,0.88);\n --bb-badge:#FF453A;\n --bb-badge-t:#fff\n}`;\n\n/* ── component ── */\nexport interface ButtonBadgeProps {\n children: React.ReactNode;\n badge?: number | string;\n onClick?: () => void;\n sound?: boolean;\n style?: React.CSSProperties;\n}\n\nexport function ButtonBadge({\n children,\n badge,\n onClick,\n sound = true,\n style,\n}: ButtonBadgeProps) {\n return (\n <>\n \n {\n onClick?.();\n if (sound) tick();\n }}\n whileHover={{ scale: 1.04 }}\n whileTap={{ scale: 0.96 }}\n transition={{ type: \"spring\", stiffness: 500, damping: 30 }}\n style={{\n position: \"relative\",\n display: \"inline-flex\",\n alignItems: \"center\",\n gap: 6,\n padding: \"8px 14px\",\n borderRadius: 10,\n border: \"1px solid var(--bb-border)\",\n background: \"var(--bb-glass)\",\n boxShadow: \"var(--bb-shadow)\",\n backdropFilter: \"blur(24px)\",\n WebkitBackdropFilter: \"blur(24px)\",\n color: \"var(--bb-hi)\",\n fontSize: 13,\n fontWeight: 500,\n cursor: \"pointer\",\n outline: \"none\",\n userSelect: \"none\",\n ...style,\n }}\n >\n {children}\n \n {badge !== undefined && (\n \n {badge}\n \n )}\n \n \n >\n );\n}\n\nexport default ButtonBadge;\n",
"type": "registry:ui",
"target": "components/ruixen/button-badge.tsx"
}
]
}