{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"flood-pills","type":"registry:ui","title":"Flood Pills","description":"Pill navigation whose items flood with a rising circle of color on hover, with a sliding active dot and a compact menu on narrow containers.","dependencies":["motion"],"registryDependencies":["utils"],"files":[{"path":"registry/ui/flood-pills.tsx","type":"registry:ui","content":"\"use client\";\n\nimport { useEffect, useId, useRef, useState, type CSSProperties, type ReactNode } from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface FloodPillsItem {\n  label: string;\n  href: string;\n}\n\nexport interface FloodPillsProps {\n  items: FloodPillsItem[];\n  /** Brand mark shown at the left. */\n  logo?: ReactNode;\n  /** Index of the active item (controlled). */\n  activeIndex?: number;\n  /** Initially active item when uncontrolled. */\n  defaultActiveIndex?: number;\n  onItemClick?: (item: FloodPillsItem, index: number) => void;\n  /** Color of the circle that floods a pill on hover. */\n  fillColor?: string;\n  /** Label color on top of the fill. */\n  fillTextColor?: string;\n  /** Fill duration in seconds. */\n  duration?: number;\n  className?: string;\n}\n\nconst ease = \"cubic-bezier(.22,.9,.24,1)\";\n\nexport function FloodPills({\n  items,\n  logo,\n  activeIndex,\n  defaultActiveIndex = 0,\n  onItemClick,\n  fillColor = \"#c6ff3d\",\n  fillTextColor = \"#0a0a0a\",\n  duration = 0.5,\n  className,\n}: FloodPillsProps) {\n  const [inner, setInner] = useState(defaultActiveIndex);\n  const [open, setOpen] = useState(false);\n  const active = activeIndex ?? inner;\n  const reduce = useReducedMotion();\n  const menuId = useId();\n  const dotId = useId();\n  const root = useRef<HTMLDivElement>(null);\n  const toggle = useRef<HTMLButtonElement>(null);\n\n  useEffect(() => {\n    if (!open) return;\n    const onKey = (e: KeyboardEvent) => {\n      if (e.key !== \"Escape\") return;\n      setOpen(false);\n      toggle.current?.focus();\n    };\n    const onDown = (e: PointerEvent) => {\n      if (!root.current?.contains(e.target as Node)) setOpen(false);\n    };\n    window.addEventListener(\"keydown\", onKey);\n    window.addEventListener(\"pointerdown\", onDown);\n    return () => {\n      window.removeEventListener(\"keydown\", onKey);\n      window.removeEventListener(\"pointerdown\", onDown);\n    };\n  }, [open]);\n\n  const select = (i: number) => {\n    if (activeIndex === undefined) setInner(i);\n    onItemClick?.(items[i], i);\n    setOpen(false);\n  };\n\n  const vars = {\n    \"--pill-fill\": fillColor,\n    \"--pill-fill-text\": fillTextColor,\n    \"--pill-t\": `${reduce ? 0 : duration}s`,\n  } as CSSProperties;\n\n  return (\n    <div ref={root} className={cn(\"@container relative w-full max-w-3xl\", className)} style={vars}>\n      <nav\n        aria-label=\"Main\"\n        className=\"flex items-center justify-between gap-2 rounded-full border border-border bg-card/80 p-1.5 shadow-[0_18px_40px_-20px_rgba(0,0,0,.6)] backdrop-blur-md\"\n      >\n        <a\n          href={items[0]?.href ?? \"#\"}\n          aria-label=\"Home\"\n          className=\"grid h-11 shrink-0 place-items-center rounded-full bg-foreground px-4 text-background outline-none transition-transform duration-300 hover:rotate-[-4deg] focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-card\"\n        >\n          {logo ?? <span className=\"size-3 rounded-full bg-[var(--pill-fill)]\" />}\n        </a>\n\n        <ul className=\"hidden items-center gap-1 @xl:flex\">\n          {items.map((item, i) => (\n            <li key={item.href + item.label}>\n              <a\n                href={item.href}\n                aria-current={i === active ? \"page\" : undefined}\n                onClick={() => select(i)}\n                className=\"group relative isolate block h-11 overflow-hidden rounded-full px-5 text-sm font-medium text-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-card\"\n              >\n                {/* The flood: a circle anchored under the pill that grows up through it. */}\n                <span\n                  aria-hidden\n                  className=\"absolute bottom-0 left-1/2 -z-10 aspect-square rounded-full bg-[var(--pill-fill)] [transform:translate(-50%,50%)_scale(0)] group-hover:[transform:translate(-50%,50%)_scale(1)] group-focus-visible:[transform:translate(-50%,50%)_scale(1)]\"\n                  style={{ width: \"max(190%, 8rem)\", transition: `transform var(--pill-t) ${ease}` }}\n                />\n                <span className=\"relative block h-full overflow-hidden\">\n                  <span\n                    className=\"flex h-11 items-center group-hover:-translate-y-full group-focus-visible:-translate-y-full\"\n                    style={{ transition: `transform var(--pill-t) ${ease}` }}\n                  >\n                    {item.label}\n                  </span>\n                  <span\n                    aria-hidden\n                    className=\"absolute inset-x-0 top-full flex h-11 items-center text-[var(--pill-fill-text)] group-hover:-translate-y-full group-focus-visible:-translate-y-full\"\n                    style={{ transition: `transform var(--pill-t) ${ease}` }}\n                  >\n                    {item.label}\n                  </span>\n                </span>\n                {i === active && (\n                  <motion.span\n                    layoutId={dotId}\n                    aria-hidden\n                    className=\"absolute bottom-1.5 left-1/2 size-1.5 -translate-x-1/2 rounded-full bg-[var(--pill-fill)] group-hover:bg-[var(--pill-fill-text)] group-focus-visible:bg-[var(--pill-fill-text)]\"\n                    transition={{ type: \"spring\", stiffness: 500, damping: 34 }}\n                  />\n                )}\n              </a>\n            </li>\n          ))}\n        </ul>\n\n        <button\n          ref={toggle}\n          type=\"button\"\n          aria-expanded={open}\n          aria-controls={menuId}\n          aria-label={open ? \"Close menu\" : \"Open menu\"}\n          onClick={() => setOpen((o) => !o)}\n          className=\"relative grid size-11 shrink-0 place-items-center rounded-full bg-muted text-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring @xl:hidden\"\n        >\n          {[-1, 1].map((s) => (\n            <motion.span\n              key={s}\n              aria-hidden\n              className=\"absolute h-[2px] w-4 rounded-full bg-current\"\n              animate={open ? { y: 0, rotate: s * 45 } : { y: s * 3.5, rotate: 0 }}\n              transition={{ type: \"spring\", stiffness: 420, damping: 26 }}\n            />\n          ))}\n        </button>\n      </nav>\n\n      <AnimatePresence>\n        {open && (\n          <motion.ul\n            id={menuId}\n            className=\"absolute inset-x-0 top-full z-20 mt-2 origin-top rounded-[1.75rem] border border-border bg-card/95 p-2 shadow-2xl backdrop-blur-md @xl:hidden\"\n            initial={reduce ? { opacity: 0 } : { opacity: 0, y: -8, scale: 0.96 }}\n            animate={{ opacity: 1, y: 0, scale: 1 }}\n            exit={reduce ? { opacity: 0 } : { opacity: 0, y: -8, scale: 0.96, transition: { duration: 0.15 } }}\n            transition={{ type: \"spring\", stiffness: 420, damping: 32 }}\n          >\n            {items.map((item, i) => (\n              <motion.li\n                key={item.href + item.label}\n                initial={reduce ? false : { opacity: 0, y: 10 }}\n                animate={{ opacity: 1, y: 0 }}\n                transition={{ delay: reduce ? 0 : 0.04 + i * 0.04 }}\n              >\n                <a\n                  href={item.href}\n                  aria-current={i === active ? \"page\" : undefined}\n                  onClick={() => select(i)}\n                  className=\"group relative isolate flex h-12 items-center justify-between overflow-hidden rounded-full px-5 text-base font-medium text-foreground outline-none hover:text-[var(--pill-fill-text)] focus-visible:text-[var(--pill-fill-text)]\"\n                  style={{ transition: `color var(--pill-t) ${ease}` }}\n                >\n                  <span\n                    aria-hidden\n                    className=\"absolute bottom-0 left-1/2 -z-10 aspect-square w-[120%] rounded-full bg-[var(--pill-fill)] [transform:translate(-50%,50%)_scale(0)] group-hover:[transform:translate(-50%,50%)_scale(1)] group-focus-visible:[transform:translate(-50%,50%)_scale(1)]\"\n                    style={{ transition: `transform var(--pill-t) ${ease}` }}\n                  />\n                  {item.label}\n                  {i === active && <span aria-hidden className=\"size-1.5 rounded-full bg-current\" />}\n                </a>\n              </motion.li>\n            ))}\n          </motion.ul>\n        )}\n      </AnimatePresence>\n    </div>\n  );\n}\n"}]}