{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"social-posts-text-post","type":"registry:component","title":"Social posts · Text post","description":"Text post with optimistic like, repost and bookmark: icons pop, the like bursts and counts roll.","author":"GetUrUI <hello@geturui.dev>","dependencies":["motion","lucide-react"],"registryDependencies":[],"files":[{"path":"registry/geturui/examples/social-posts/text-post.tsx","type":"registry:component","target":"components/examples/social-posts/text-post.tsx","content":"\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { BadgeCheck, BarChart2, Bookmark, Heart, MessageCircle, MoreHorizontal, Repeat2, type LucideIcon } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface TextPostProps {\n  author?: string;\n  handle?: string;\n  verified?: boolean;\n  /** Relative time label, e.g. \"2h\". */\n  time?: string;\n  /** Paragraphs of the post. */\n  body?: string[];\n  replies?: number;\n  reposts?: number;\n  likes?: number;\n  views?: number;\n  defaultLiked?: boolean;\n  defaultReposted?: boolean;\n  defaultBookmarked?: boolean;\n  onReply?: () => void;\n  onChange?: (state: { liked: boolean; reposted: boolean; bookmarked: boolean }) => void;\n  className?: string;\n}\n\nconst compact = (n: number) => new Intl.NumberFormat(\"en-US\", { notation: \"compact\", maximumFractionDigits: 1 }).format(n);\nconst spring = { type: \"spring\", stiffness: 480, damping: 30 } as const;\nconst BURST = Array.from({ length: 6 }, (_, i) => ({ x: Math.cos((i / 6) * Math.PI * 2) * 16, y: Math.sin((i / 6) * Math.PI * 2) * 16 }));\n\nfunction Rolling({ value, up, reduce }: { value: number; up: boolean; reduce: boolean }) {\n  return (\n    <span className=\"relative inline-flex overflow-hidden tabular-nums\">\n      <AnimatePresence mode=\"popLayout\" initial={false}>\n        <motion.span key={value} initial={reduce ? { opacity: 0 } : { y: up ? 12 : -12, opacity: 0 }} animate={{ y: 0, opacity: 1 }} exit={reduce ? { opacity: 0 } : { y: up ? -12 : 12, opacity: 0 }} transition={spring}>\n          {compact(value)}\n        </motion.span>\n      </AnimatePresence>\n    </span>\n  );\n}\n\nfunction Pop({ on, Icon, fill, reduce }: { on: boolean; Icon: LucideIcon; fill?: boolean; reduce: boolean }) {\n  return (\n    <motion.span initial={reduce || !on ? false : { scale: 0.4 }} animate={{ scale: 1 }} transition={{ type: \"spring\", stiffness: 600, damping: 13 }} className=\"grid\">\n      <Icon aria-hidden className={cn(\"size-[18px]\", on && fill && \"fill-current\")} strokeWidth={on && !fill ? 2.6 : 2} />\n    </motion.span>\n  );\n}\n\n/** Text post with optimistic like, repost and bookmark toggles: icons pop, the like bursts and every count rolls to its new value. */\nexport function TextPost({\n  author = \"Maya Kerrigan\",\n  handle = \"@mayamakes\",\n  verified = true,\n  time = \"2h\",\n  body = [\n    \"Hot take after a year of shipping motion in production: most interfaces don't need more animation, they need shorter animation.\",\n    \"We cut our default duration from 400ms to 180ms and support tickets about the app feeling slow dropped by a third.\",\n  ],\n  replies = 48,\n  reposts = 212,\n  likes = 1840,\n  views = 48200,\n  defaultLiked = false,\n  defaultReposted = false,\n  defaultBookmarked = false,\n  onReply,\n  onChange,\n  className,\n}: TextPostProps) {\n  const reduce = useReducedMotion() ?? false;\n  const [state, setState] = React.useState({ liked: defaultLiked, reposted: defaultReposted, bookmarked: defaultBookmarked });\n  const [burst, setBurst] = React.useState(0);\n  const id = React.useId();\n\n  function flip(key: keyof typeof state) {\n    const next = { ...state, [key]: !state[key] };\n    setState(next);\n    onChange?.(next);\n    if (key === \"liked\" && next.liked && !reduce) setBurst((b) => b + 1);\n  }\n\n  const likeCount = likes + (state.liked ? 1 : 0) - (defaultLiked ? 1 : 0);\n  const repostCount = reposts + (state.reposted ? 1 : 0) - (defaultReposted ? 1 : 0);\n  const action = \"group/a inline-flex h-8 items-center gap-1.5 rounded-full px-2 text-[12.5px] outline-none transition-colors focus-visible:shadow-[var(--focus-ring)]\";\n\n  return (\n    <article aria-labelledby={`${id}-a`} className={cn(\"w-full max-w-[520px] rounded-xl border border-border bg-surface-raised p-4 shadow-sm\", className)}>\n      <header className=\"flex items-start gap-3\">\n        <span aria-hidden className=\"grid size-10 shrink-0 place-items-center rounded-full bg-ink font-display text-[13px] font-semibold text-bg\">\n          {author.split(\" \").map((p) => p[0]).join(\"\").slice(0, 2)}\n        </span>\n        <div className=\"min-w-0 flex-1\">\n          <p id={`${id}-a`} className=\"flex items-center gap-1 text-[14px] font-semibold text-ink\">\n            <span className=\"truncate\">{author}</span>\n            {verified && <BadgeCheck aria-label=\"Verified\" className=\"size-4 shrink-0 text-volt-ink\" />}\n          </p>\n          <p className=\"text-[12.5px] text-ink-subtle\">\n            {handle} · {time}\n          </p>\n        </div>\n        <button type=\"button\" aria-label=\"More options\" className=\"grid size-8 place-items-center rounded-full text-ink-subtle outline-none transition-colors hover:bg-surface-hover hover:text-ink focus-visible:shadow-[var(--focus-ring)]\">\n          <MoreHorizontal aria-hidden className=\"size-4\" />\n        </button>\n      </header>\n\n      <div className=\"mt-3 space-y-2.5 text-[14.5px] leading-[1.55] text-ink\">\n        {body.map((p, i) => (\n          <p key={i}>{p}</p>\n        ))}\n      </div>\n\n      <div className=\"-mx-2 mt-3 flex items-center justify-between\">\n        <button type=\"button\" onClick={onReply} aria-label={`Reply, ${replies} replies`} className={cn(action, \"text-ink-subtle hover:bg-surface-hover hover:text-ink\")}>\n          <MessageCircle aria-hidden className=\"size-[18px]\" />\n          {compact(replies)}\n        </button>\n        <button type=\"button\" aria-pressed={state.reposted} aria-label={`Repost, ${repostCount} reposts`} onClick={() => flip(\"reposted\")} className={cn(action, state.reposted ? \"font-semibold text-ink\" : \"text-ink-subtle\", \"hover:bg-surface-hover hover:text-ink\")}>\n          <Pop key={`r${state.reposted}`} on={state.reposted} Icon={Repeat2} reduce={reduce} />\n          <Rolling value={repostCount} up={state.reposted} reduce={reduce} />\n        </button>\n        <button type=\"button\" aria-pressed={state.liked} aria-label={`Like, ${likeCount} likes`} onClick={() => flip(\"liked\")} className={cn(action, state.liked ? \"font-semibold text-volt-ink\" : \"text-ink-subtle\", \"relative hover:bg-surface-hover\")}>\n          <span className=\"relative grid\">\n            <AnimatePresence>\n              {burst > 0 &&\n                BURST.map((b, i) => (\n                  <motion.span\n                    key={`${burst}-${i}`}\n                    aria-hidden\n                    initial={{ x: 0, y: 0, opacity: 1, scale: 1 }}\n                    animate={{ x: b.x, y: b.y, opacity: 0, scale: 0.3 }}\n                    transition={{ duration: 0.5, ease: [0.22, 1, 0.36, 1] }}\n                    className=\"absolute left-1/2 top-1/2 -ml-0.5 -mt-0.5 size-1 rounded-full bg-volt-ink\"\n                  />\n                ))}\n            </AnimatePresence>\n            <Pop key={`l${state.liked}`} on={state.liked} Icon={Heart} fill reduce={reduce} />\n          </span>\n          <Rolling value={likeCount} up={state.liked} reduce={reduce} />\n        </button>\n        <span className=\"inline-flex items-center gap-1.5 px-2 text-[12.5px] text-ink-subtle\">\n          <BarChart2 aria-hidden className=\"size-[18px]\" />\n          <span className=\"sr-only\">Views</span>\n          {compact(views)}\n        </span>\n        <button type=\"button\" aria-pressed={state.bookmarked} aria-label={state.bookmarked ? \"Remove bookmark\" : \"Bookmark\"} onClick={() => flip(\"bookmarked\")} className={cn(action, state.bookmarked ? \"text-ink\" : \"text-ink-subtle\", \"hover:bg-surface-hover hover:text-ink\")}>\n          <Pop key={`b${state.bookmarked}`} on={state.bookmarked} Icon={Bookmark} fill reduce={reduce} />\n        </button>\n      </div>\n    </article>\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","social","post","feed","like","repost","poll","image grid","link preview","timeline"],"meta":{"tier":"free","license":"MIT","docs":"https://geturui.com/docs/social-posts#text-post"}}