{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "carousel",
  "type": "registry:component",
  "title": "Carousel",
  "description": "3–8 comparable items with tall images, save toggle, rating and meta row, edge fade and next button. Based on the MCP Apps for Claude kit.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "https://mcpblocks.dev/r/host-tokens.json",
    "https://mcpblocks.dev/r/host.json",
    "https://mcpblocks.dev/r/icons.json"
  ],
  "files": [
    {
      "path": "registry/mcpblocks/components/carousel.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n// The kit has no bookmark icon, so this one comes from lucide.\nimport { Bookmark } from \"lucide-react\"\n\nimport { cn } from \"@/lib/utils\"\nimport { guideline } from \"@/registry/mcpblocks/lib/host\"\nimport { CaretLeftIcon, CaretRightIcon, StarFilledIcon } from \"@/registry/mcpblocks/ui/icons\"\n\nexport type CarouselItem = {\n  id: string\n  title: string\n  subtitle?: string\n  image?: string\n  imageAlt?: string\n  /** Star rating shown first in the meta row, e.g. 4.6. */\n  rating?: number\n  /** Short facts joined with dots, e.g. [\"Moderate\", \"2.8 mi\"]. */\n  meta?: string[]\n  /** Optional save/bookmark toggle on the image. */\n  saved?: boolean\n  onSave?: (saved: boolean) => void\n  onClick?: () => void\n}\n\nexport type CarouselProps = {\n  /** Claude guidelines: 3–8 items. */\n  items: CarouselItem[]\n  /** Accessible label for the scroll region. */\n  label?: string\n  /** Card width and image height in px (kit default 220 × 280). */\n  cardWidth?: number\n  imageHeight?: number\n  className?: string\n}\n\n/**\n * Horizontal row of comparable items with images, a save toggle and a meta row.\n * Matches the \"Inline carousel\" pattern in the MCP Apps for Claude kit.\n * Register the resource with `_meta.ui.prefersBorder: false`.\n */\nexport function Carousel({\n  items,\n  label = \"Options\",\n  cardWidth = 220,\n  imageHeight = 280,\n  className,\n}: CarouselProps) {\n  guideline(items.length < 3 || items.length > 8, \"Carousel: Claude recommends 3–8 items.\")\n  const scroller = React.useRef<HTMLDivElement>(null)\n  const [edges, setEdges] = React.useState({ start: true, end: false })\n  const [saved, setSaved] = React.useState<Record<string, boolean>>(() =>\n    Object.fromEntries(items.map((i) => [i.id, !!i.saved]))\n  )\n\n  const updateEdges = React.useCallback(() => {\n    const el = scroller.current\n    if (!el) return\n    setEdges({ start: el.scrollLeft <= 4, end: el.scrollLeft + el.clientWidth >= el.scrollWidth - 4 })\n  }, [])\n\n  React.useEffect(() => {\n    updateEdges()\n    const el = scroller.current\n    if (!el) return\n    const ro = new ResizeObserver(updateEdges)\n    ro.observe(el)\n    return () => ro.disconnect()\n  }, [updateEdges])\n\n  function page(dir: 1 | -1) {\n    scroller.current?.scrollBy({ left: dir * (cardWidth + 12) * 2, behavior: \"smooth\" })\n  }\n\n  const fade = !edges.end\n    ? \"linear-gradient(to right, black calc(100% - 172px), transparent)\"\n    : undefined\n\n  return (\n    <div data-slot=\"carousel\" className={cn(\"relative w-full pt-4 pb-6 text-host-fg font-[family-name:var(--font-sans)]\", className)}>\n      <div\n        ref={scroller}\n        role=\"region\"\n        aria-label={label}\n        tabIndex={0}\n        onScroll={updateEdges}\n        className=\"flex snap-x snap-mandatory gap-3 overflow-x-auto px-4 outline-none [scrollbar-width:none] [&::-webkit-scrollbar]:hidden\"\n        style={{\n          maskImage: fade,\n          WebkitMaskImage: fade,\n          scrollPaddingInline: \"max(16px, var(--mb-safe-left, 0px)) max(16px, var(--mb-safe-right, 0px))\",\n        }}\n      >\n        {items.map((item) => {\n          const isSaved = saved[item.id]\n          return (\n            <article key={item.id} className=\"flex shrink-0 snap-start flex-col gap-5\" style={{ width: cardWidth }}>\n              <div className=\"relative overflow-hidden rounded-host-xl bg-host-bg-secondary\" style={{ height: imageHeight }}>\n                {item.image ? (\n                  // eslint-disable-next-line @next/next/no-img-element\n                  <img src={item.image} alt={item.imageAlt ?? \"\"} className=\"size-full object-cover\" />\n                ) : null}\n                {item.onSave !== undefined || item.saved !== undefined ? (\n                  <button\n                    type=\"button\"\n                    aria-pressed={isSaved}\n                    aria-label={isSaved ? `Remove ${item.title} from saved` : `Save ${item.title}`}\n                    onClick={() => {\n                      const next = !isSaved\n                      setSaved((s) => ({ ...s, [item.id]: next }))\n                      item.onSave?.(next)\n                    }}\n                    className=\"absolute top-3 right-3 inline-flex size-11 items-center justify-center rounded-full border-[length:var(--border-width-regular,0.5px)] border-host-border-tertiary bg-host-bg/90 text-host-fg backdrop-blur-[9px]\"\n                  >\n                    <Bookmark className=\"size-5\" fill={isSaved ? \"currentColor\" : \"none\"} aria-hidden=\"true\" />\n                  </button>\n                ) : null}\n              </div>\n\n              <div className=\"flex flex-col gap-2.5\">\n                {item.onClick ? (\n                  <button type=\"button\" onClick={item.onClick} className=\"truncate text-left text-xs leading-[1.4] font-semibold text-host-fg-secondary hover:underline\">\n                    {item.title}\n                  </button>\n                ) : (\n                  <h3 className=\"truncate text-xs leading-[1.4] font-semibold text-host-fg-secondary\">{item.title}</h3>\n                )}\n                {item.subtitle ? <p className=\"truncate text-xs leading-[1.4] text-host-fg-secondary\">{item.subtitle}</p> : null}\n                {item.rating !== undefined || item.meta?.length ? (\n                  <p className=\"flex items-center gap-1 text-xs leading-[1.4] text-host-fg-tertiary opacity-75\">\n                    {item.rating !== undefined ? (\n                      <span className=\"flex items-center gap-0.5\">\n                        <StarFilledIcon className=\"size-4\" aria-label=\"Rating\" />\n                        {item.rating}\n                      </span>\n                    ) : null}\n                    {item.meta?.map((m, i) => (\n                      <React.Fragment key={m}>\n                        {i > 0 || item.rating !== undefined ? (\n                          <span aria-hidden=\"true\" className=\"size-[3px] rounded-full bg-current\" />\n                        ) : null}\n                        <span className=\"truncate\">{m}</span>\n                      </React.Fragment>\n                    ))}\n                  </p>\n                ) : null}\n              </div>\n            </article>\n          )\n        })}\n        <div aria-hidden=\"true\" className=\"w-4 shrink-0\" />\n      </div>\n\n      {!edges.start ? (\n        <button\n          type=\"button\"\n          aria-label=\"Previous\"\n          onClick={() => page(-1)}\n          className=\"absolute top-[calc(16px+var(--img-h)/2)] left-2 inline-flex size-11 -translate-y-1/2 items-center justify-center rounded-full border-[length:var(--border-width-regular,0.5px)] border-host-border-tertiary bg-host-bg text-host-fg shadow-md\"\n          style={{ [\"--img-h\" as string]: `${imageHeight}px` }}\n        >\n          <CaretLeftIcon className=\"size-5\" />\n        </button>\n      ) : null}\n      {!edges.end ? (\n        <button\n          type=\"button\"\n          aria-label=\"Next\"\n          onClick={() => page(1)}\n          className=\"absolute top-[calc(16px+var(--img-h)/2)] right-2 inline-flex size-11 -translate-y-1/2 items-center justify-center rounded-full border-[length:var(--border-width-regular,0.5px)] border-host-border-tertiary bg-host-bg text-host-fg shadow-md\"\n          style={{ [\"--img-h\" as string]: `${imageHeight}px` }}\n        >\n          <CaretRightIcon className=\"size-5\" />\n        </button>\n      ) : null}\n    </div>\n  )\n}\n",
      "type": "registry:component"
    }
  ]
}