{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"chat-bubbles-group-reactions","type":"registry:component","title":"Chat bubbles · Group reactions","description":"Group chat with grouped senders, toggleable reaction pills whose counts roll and an inline reaction picker.","author":"GetUrUI <hello@geturui.dev>","dependencies":["motion","lucide-react"],"registryDependencies":[],"files":[{"path":"registry/geturui/examples/chat-bubbles/group-reactions.tsx","type":"registry:component","target":"components/examples/chat-bubbles/group-reactions.tsx","content":"\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { Heart, Laugh, SmilePlus, Sparkles, ThumbsUp, type LucideIcon } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport type ReactionKey = \"agree\" | \"love\" | \"brilliant\" | \"funny\";\n\nexport interface GroupMessage {\n  id: string;\n  author: string;\n  time: string;\n  text: string;\n  /** Count from other people per reaction. */\n  reactions?: Partial<Record<ReactionKey, number>>;\n  /** Reactions the current user has added. */\n  mine?: ReactionKey[];\n}\n\nexport interface GroupChatProps {\n  channel?: string;\n  members?: number;\n  messages?: GroupMessage[];\n  onReact?: (messageId: string, reaction: ReactionKey, active: boolean) => void;\n  className?: string;\n}\n\nconst REACTIONS: { key: ReactionKey; label: string; Icon: LucideIcon }[] = [\n  { key: \"agree\", label: \"Agree\", Icon: ThumbsUp },\n  { key: \"love\", label: \"Love\", Icon: Heart },\n  { key: \"brilliant\", label: \"Brilliant\", Icon: Sparkles },\n  { key: \"funny\", label: \"Funny\", Icon: Laugh },\n];\n\nconst DEFAULT_MESSAGES: GroupMessage[] = [\n  { id: \"g1\", author: \"Priya Nair\", time: \"10:02\", text: \"Launch checklist is green. Docs, changelog and the pricing page are live on staging.\", reactions: { agree: 3, love: 1 } },\n  { id: \"g2\", author: \"Priya Nair\", time: \"10:02\", text: \"Can someone give the hero animation one last look on a slow phone?\" },\n  { id: \"g3\", author: \"Jonah Reyes\", time: \"10:05\", text: \"Checked on a four-year-old Android. Smooth, and it falls back to a fade with reduced motion on.\", reactions: { brilliant: 2 }, mine: [\"agree\"] },\n  { id: \"g4\", author: \"Theo Lind\", time: \"10:07\", text: \"Then we ship at 11. I'll post in the announcements channel.\", reactions: { love: 4, funny: 1 } },\n];\n\nconst TONES = [\"bg-ink text-bg\", \"bg-surface-sunken text-ink border border-border\", \"bg-ember-soft text-ember-ink\"];\nconst initialsOf = (n: string) => n.split(/\\s+/).map((p) => p[0]).slice(0, 2).join(\"\").toUpperCase();\nconst spring = { type: \"spring\", stiffness: 420, damping: 30 } as const;\n\n/** Group chat with grouped senders, toggleable reaction pills whose counts roll, and an inline reaction picker per message. */\nexport function GroupChat({ channel = \"launch-week\", members = 8, messages = DEFAULT_MESSAGES, onReact, className }: GroupChatProps) {\n  const reduce = useReducedMotion() ?? false;\n  const [mine, setMine] = React.useState<Record<string, ReactionKey[]>>(() => Object.fromEntries(messages.map((m) => [m.id, m.mine ?? []])));\n  const [picker, setPicker] = React.useState<string | null>(null);\n  const authors = Array.from(new Set(messages.map((m) => m.author)));\n\n  function toggle(messageId: string, key: ReactionKey) {\n    const has = mine[messageId]?.includes(key) ?? false;\n    setMine((s) => ({ ...s, [messageId]: has ? s[messageId].filter((k) => k !== key) : [...(s[messageId] ?? []), key] }));\n    onReact?.(messageId, key, !has);\n  }\n\n  return (\n    <section aria-label={`#${channel}`} className={cn(\"w-full max-w-[460px] rounded-xl border border-border bg-surface-raised shadow-sm\", className)}>\n      <header className=\"flex items-center justify-between border-b border-border px-4 py-3\">\n        <p className=\"font-display text-[15px] font-semibold text-ink\">\n          <span className=\"text-ink-subtle\">#</span>\n          {channel}\n        </p>\n        <p className=\"text-xs text-ink-subtle\">{members} members</p>\n      </header>\n      <ol className=\"flex flex-col px-2 py-3\">\n        {messages.map((m, i) => {\n          const first = messages[i - 1]?.author !== m.author;\n          const active = mine[m.id] ?? [];\n          const shown = REACTIONS.filter((r) => (m.reactions?.[r.key] ?? 0) + (active.includes(r.key) ? 1 : 0) > 0);\n          const tone = TONES[authors.indexOf(m.author) % TONES.length];\n          return (\n            <li\n              key={m.id}\n              onKeyDown={(e) => {\n                if (e.key !== \"Escape\" || picker !== m.id) return;\n                setPicker(null);\n                e.currentTarget.querySelector<HTMLButtonElement>(\"[data-add-reaction]\")?.focus();\n              }}\n              className={cn(\"group relative flex gap-3 rounded-lg px-2 py-1 transition-colors hover:bg-surface-hover\", first && i > 0 && \"mt-2\")}\n            >\n              <span aria-hidden className={cn(\"mt-0.5 grid size-8 shrink-0 place-items-center rounded-full font-display text-[11px] font-semibold\", first ? tone : \"invisible\")}>\n                {initialsOf(m.author)}\n              </span>\n              <div className=\"min-w-0 flex-1\">\n                {first && (\n                  <p className=\"flex items-baseline gap-2\">\n                    <span className=\"text-[13.5px] font-semibold text-ink\">{m.author}</span>\n                    <span className=\"text-[11px] text-ink-subtle\">{m.time}</span>\n                  </p>\n                )}\n                <p className=\"text-[13.5px] leading-5 text-ink-muted\">{m.text}</p>\n                {shown.length > 0 && (\n                  <div className=\"mt-1.5 flex flex-wrap gap-1\">\n                    {shown.map(({ key, label, Icon }) => {\n                      const on = active.includes(key);\n                      const n = (m.reactions?.[key] ?? 0) + (on ? 1 : 0);\n                      return (\n                        <motion.button\n                          key={key}\n                          type=\"button\"\n                          layout={!reduce}\n                          initial={reduce ? false : { scale: 0.6, opacity: 0 }}\n                          animate={{ scale: 1, opacity: 1 }}\n                          whileTap={reduce ? undefined : { scale: 0.9 }}\n                          transition={spring}\n                          aria-pressed={on}\n                          aria-label={`${label}, ${n} ${n === 1 ? \"reaction\" : \"reactions\"}`}\n                          onClick={() => toggle(m.id, key)}\n                          className={cn(\n                            \"inline-flex h-6 items-center gap-1 rounded-full border px-2 text-[11.5px] font-medium outline-none transition-colors focus-visible:shadow-[var(--focus-ring)]\",\n                            on ? \"border-volt-ink/40 bg-volt-soft text-ink\" : \"border-border bg-surface text-ink-muted hover:border-border-strong\",\n                          )}\n                        >\n                          <Icon aria-hidden className={cn(\"size-3\", on && \"text-volt-ink\")} strokeWidth={2.4} />\n                          <span className=\"relative inline-flex overflow-hidden tabular-nums\">\n                            <AnimatePresence mode=\"popLayout\" initial={false}>\n                              <motion.span key={n} initial={{ y: reduce ? 0 : 10, opacity: 0 }} animate={{ y: 0, opacity: 1 }} exit={{ y: reduce ? 0 : -10, opacity: 0 }} transition={spring}>\n                                {n}\n                              </motion.span>\n                            </AnimatePresence>\n                          </span>\n                        </motion.button>\n                      );\n                    })}\n                  </div>\n                )}\n              </div>\n\n              <div className=\"absolute -top-3 right-2 z-10 flex items-center\">\n                <AnimatePresence>\n                  {picker === m.id && (\n                    <motion.div\n                      role=\"group\"\n                      aria-label=\"Pick a reaction\"\n                      initial={{ opacity: 0, scale: reduce ? 1 : 0.85, x: reduce ? 0 : 8 }}\n                      animate={{ opacity: 1, scale: 1, x: 0 }}\n                      exit={{ opacity: 0, scale: reduce ? 1 : 0.85 }}\n                      transition={spring}\n                      className=\"mr-1 flex origin-right gap-0.5 rounded-full border border-border bg-surface-raised p-1 shadow-md\"\n                    >\n                      {REACTIONS.map(({ key, label, Icon }, j) => (\n                        <button\n                          key={key}\n                          type=\"button\"\n                          autoFocus={j === 0}\n                          aria-label={label}\n                          aria-pressed={active.includes(key)}\n                          onClick={() => {\n                            toggle(m.id, key);\n                            setPicker(null);\n                          }}\n                          className=\"grid size-7 place-items-center rounded-full text-ink-muted outline-none transition-colors hover:bg-surface-hover hover:text-ink focus-visible:shadow-[var(--focus-ring)] aria-pressed:text-volt-ink\"\n                        >\n                          <Icon aria-hidden className=\"size-3.5\" />\n                        </button>\n                      ))}\n                    </motion.div>\n                  )}\n                </AnimatePresence>\n                <button\n                  type=\"button\"\n                  data-add-reaction\n                  aria-label=\"Add reaction\"\n                  aria-expanded={picker === m.id}\n                  onClick={() => setPicker((p) => (p === m.id ? null : m.id))}\n                  className={cn(\n                    \"grid size-7 place-items-center rounded-full border border-border bg-surface-raised text-ink-muted shadow-sm outline-none transition-opacity hover:text-ink focus-visible:opacity-100 focus-visible:shadow-[var(--focus-ring)]\",\n                    picker === m.id ? \"opacity-100\" : \"opacity-0 group-hover:opacity-100 [@media(hover:none)]:opacity-100\",\n                  )}\n                >\n                  <SmilePlus aria-hidden className=\"size-3.5\" />\n                </button>\n              </div>\n            </li>\n          );\n        })}\n      </ol>\n    </section>\n  );\n}\n"},{"path":"LICENSE-geturui.md","type":"registry:file","target":"LICENSE-geturui.md","content":"MIT License\n\nCopyright (c) 2026 geturui.com\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"}],"categories":["examples","chat","message","bubble","support","typing indicator","reactions","voice note","attachment","read receipt"],"meta":{"tier":"free","license":"MIT","docs":"https://geturui.com/docs/chat-bubbles#group-reactions"}}