{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"chat-bubbles-delivery-states","type":"registry:component","title":"Chat bubbles · Delivery states","description":"Direct-message thread where sent messages animate through sending, sent, delivered and read, with retry on failure.","author":"GetUrUI <hello@geturui.dev>","dependencies":["motion","lucide-react"],"registryDependencies":[],"files":[{"path":"registry/geturui/examples/chat-bubbles/delivery-states.tsx","type":"registry:component","target":"components/examples/chat-bubbles/delivery-states.tsx","content":"\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { AlertCircle, ArrowUp, Check, CheckCheck, Clock3, RotateCw } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport type DeliveryStatus = \"sending\" | \"sent\" | \"delivered\" | \"read\" | \"failed\";\n\nexport interface DeliveryMessage {\n  id: string;\n  mine: boolean;\n  text: string;\n  time: string;\n  status?: DeliveryStatus;\n}\n\nexport interface DeliveryStatesProps {\n  contact?: string;\n  messages?: DeliveryMessage[];\n  /** Walk new messages through sent, delivered and read. */\n  autoRead?: boolean;\n  onSend?: (text: string) => void;\n  onRetry?: (id: string) => void;\n  className?: string;\n}\n\nconst DEFAULT_MESSAGES: DeliveryMessage[] = [\n  { id: \"d1\", mine: false, text: \"Are the new invoice templates ready for review?\", time: \"9:30\" },\n  { id: \"d2\", mine: true, text: \"Yes, both versions are in the shared folder.\", time: \"9:31\", status: \"read\" },\n  { id: \"d3\", mine: true, text: \"The second one has the tax breakdown you asked for.\", time: \"9:32\", status: \"delivered\" },\n  { id: \"d4\", mine: true, text: \"Sending the PDF export now.\", time: \"9:33\", status: \"failed\" },\n];\n\nconst LABEL: Record<DeliveryStatus, string> = { sending: \"Sending\", sent: \"Sent\", delivered: \"Delivered\", read: \"Read\", failed: \"Not delivered\" };\nconst STEPS: [DeliveryStatus, number][] = [[\"sent\", 700], [\"delivered\", 1500], [\"read\", 2800]];\n\nfunction StatusIcon({ status }: { status: DeliveryStatus }) {\n  const cls = \"size-3.5\";\n  if (status === \"sending\") return <Clock3 aria-hidden className={cls} />;\n  if (status === \"sent\") return <Check aria-hidden className={cls} strokeWidth={2.5} />;\n  if (status === \"failed\") return <AlertCircle aria-hidden className={cn(cls, \"text-danger\")} />;\n  return <CheckCheck aria-hidden className={cn(cls, status === \"read\" && \"text-volt-ink\")} strokeWidth={2.5} />;\n}\n\n/** Direct-message thread where each sent message animates through sending, sent, delivered and read, with a failed state you can retry. */\nexport function DeliveryStates({ contact = \"Theo Lind\", messages = DEFAULT_MESSAGES, autoRead = true, onSend, onRetry, className }: DeliveryStatesProps) {\n  const reduce = useReducedMotion() ?? false;\n  const [list, setList] = React.useState(messages);\n  const [draft, setDraft] = React.useState(\"\");\n  const timers = React.useRef<ReturnType<typeof setTimeout>[]>([]);\n  const seq = React.useRef(0);\n  const inputId = React.useId();\n\n  React.useEffect(() => {\n    const pending = timers.current;\n    return () => pending.forEach(clearTimeout);\n  }, []);\n\n  function setStatus(id: string, status: DeliveryStatus) {\n    setList((l) => l.map((m) => (m.id === id ? { ...m, status } : m)));\n  }\n\n  function walk(id: string, fail = false) {\n    setStatus(id, \"sending\");\n    if (fail) return;\n    STEPS.filter(([s]) => autoRead || s !== \"read\").forEach(([s, ms]) => timers.current.push(setTimeout(() => setStatus(id, s), ms)));\n  }\n\n  function send(e: React.FormEvent) {\n    e.preventDefault();\n    const text = draft.trim();\n    if (!text) return;\n    seq.current += 1;\n    const id = `new-${seq.current}`;\n    setList((l) => [...l, { id, mine: true, text, time: \"Now\", status: \"sending\" }]);\n    setDraft(\"\");\n    onSend?.(text);\n    walk(id);\n  }\n\n  const lastRead = list.reduce((acc, m, i) => (m.mine && m.status === \"read\" ? i : acc), -1);\n  const lastMine = list.reduce((acc, m, i) => (m.mine ? i : acc), -1);\n\n  return (\n    <section aria-label={`Messages with ${contact}`} className={cn(\"flex w-full max-w-[400px] flex-col rounded-xl border border-border bg-surface-raised shadow-sm\", className)}>\n      <header className=\"flex items-center gap-3 border-b border-border px-4 py-3\">\n        <span aria-hidden className=\"grid size-8 place-items-center rounded-full bg-surface-sunken font-display text-[12px] font-semibold text-ink\">\n          {contact.split(\" \").map((p) => p[0]).join(\"\")}\n        </span>\n        <p className=\"text-[14px] font-semibold text-ink\">{contact}</p>\n      </header>\n\n      <ol aria-live=\"polite\" className=\"flex max-h-[320px] min-h-[240px] flex-col gap-1.5 overflow-y-auto px-4 py-4\">\n        <AnimatePresence initial={false}>\n          {list.map((m, i) => {\n            const status = m.status;\n            return (\n              <motion.li\n                key={m.id}\n                layout={reduce ? false : \"position\"}\n                initial={reduce ? { opacity: 0 } : { opacity: 0, y: 12, scale: 0.95 }}\n                animate={{ opacity: 1, y: 0, scale: 1 }}\n                transition={{ type: \"spring\", stiffness: 380, damping: 30 }}\n                style={{ originX: m.mine ? 1 : 0 }}\n                className={cn(\"flex flex-col\", m.mine ? \"items-end\" : \"items-start\")}\n              >\n                <p\n                  className={cn(\n                    \"max-w-[82%] rounded-lg px-3.5 py-2 text-[13.5px] leading-5 transition-opacity\",\n                    m.mine ? \"rounded-br-xs bg-ink text-bg\" : \"rounded-bl-xs border border-border bg-surface text-ink\",\n                    status === \"sending\" && \"opacity-70\",\n                    status === \"failed\" && \"opacity-80\",\n                  )}\n                >\n                  {m.text}\n                </p>\n                {m.mine && status && (\n                  <div className=\"mt-1 flex h-5 items-center gap-1.5 px-1 text-[11px] text-ink-subtle\">\n                    <span>{m.time}</span>\n                    <AnimatePresence mode=\"popLayout\" initial={false}>\n                      <motion.span\n                        key={status}\n                        initial={{ opacity: 0, scale: reduce ? 1 : 0.5, filter: \"blur(4px)\" }}\n                        animate={{ opacity: 1, scale: 1, filter: \"blur(0px)\" }}\n                        exit={{ opacity: 0, scale: reduce ? 1 : 0.5 }}\n                        transition={{ type: \"spring\", stiffness: 520, damping: 28 }}\n                        className={cn(\"inline-flex items-center gap-1\", status === \"failed\" && \"text-danger\")}\n                      >\n                        <StatusIcon status={status} />\n                        {status === \"failed\" || i === lastRead || i === lastMine ? LABEL[status] : <span className=\"sr-only\">{LABEL[status]}</span>}\n                      </motion.span>\n                    </AnimatePresence>\n                    {status === \"failed\" && (\n                      <button\n                        type=\"button\"\n                        onClick={() => {\n                          onRetry?.(m.id);\n                          walk(m.id);\n                        }}\n                        className=\"inline-flex items-center gap-1 rounded-full px-1.5 font-medium text-ink outline-none underline-offset-2 hover:underline focus-visible:shadow-[var(--focus-ring)]\"\n                      >\n                        <RotateCw aria-hidden className=\"size-3\" />\n                        Retry\n                      </button>\n                    )}\n                  </div>\n                )}\n              </motion.li>\n            );\n          })}\n        </AnimatePresence>\n      </ol>\n\n      <form onSubmit={send} className=\"flex items-center gap-2 border-t border-border p-3\">\n        <label htmlFor={inputId} className=\"sr-only\">\n          Message {contact}\n        </label>\n        <input\n          id={inputId}\n          value={draft}\n          onChange={(e) => setDraft(e.target.value)}\n          placeholder=\"Write a message\"\n          autoComplete=\"off\"\n          className=\"h-10 min-w-0 flex-1 rounded-full border border-border-strong bg-surface px-4 text-[13.5px] text-ink outline-none placeholder:text-ink-subtle focus-visible:shadow-[var(--focus-ring)]\"\n        />\n        <motion.button\n          type=\"submit\"\n          aria-label=\"Send message\"\n          disabled={!draft.trim()}\n          whileTap={reduce ? undefined : { scale: 0.9 }}\n          className=\"grid size-10 shrink-0 place-items-center rounded-full bg-volt text-on-volt outline-none transition-colors focus-visible:shadow-[var(--focus-ring)] disabled:bg-surface-sunken disabled:text-ink-subtle\"\n        >\n          <ArrowUp aria-hidden className=\"size-4\" strokeWidth={2.5} />\n        </motion.button>\n      </form>\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#delivery-states"}}