{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "gooey-tab-bar",
  "title": "Gooey Tab Bar",
  "description": "An accessible tab bar with a filtered liquid indicator and trailing blob, automatic active-tab measurement, roving keyboard focus and reduced-motion support.",
  "dependencies": [
    "motion",
    "lucide-react",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/gooey-tab-bar/gooey-tab-bar.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion } from \"motion/react\";\nimport { UserRound, House, Compass, Heart } from \"lucide-react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); }\n\nexport type NavbarTheme = \"dark\" | \"light\";\n\nfunction palette(theme: NavbarTheme): React.CSSProperties & Record<`--${string}`, string> {\n const light=theme===\"light\";\n return {\"--nav-page\":light?\"#f5f4f1\":\"#0e0e0e\",\"--nav-ink\":light?\"#0a0a0a\":\"#f5f4f1\",\"--nav-muted\":light?\"rgba(10,10,10,.52)\":\"rgba(245,244,241,.52)\",\"--nav-line\":light?\"rgba(10,10,10,.1)\":\"rgba(245,244,241,.1)\",\"--nav-soft\":light?\"rgba(10,10,10,.045)\":\"rgba(245,244,241,.045)\",\"--nav-panel\":light?\"rgba(245,244,241,.96)\":\"rgba(14,14,14,.96)\",\"--nav-serif\":\"var(--navbar-serif, 'Instrument Serif', Georgia, serif)\"};\n}\n\nconst focus=\"outline-none focus-visible:ring-2 focus-visible:ring-[var(--nav-ink)]/40 focus-visible:ring-offset-4 focus-visible:ring-offset-[var(--nav-page)]\";\n\nconst muted=\"text-[color:var(--nav-muted)]\";\n\nfunction useActive(value:string|undefined,initial:string,onChange?:(id:string)=>void){const[internal,setInternal]=React.useState(initial);const active=value??internal;const setActive=(id:string)=>{if(value===undefined)setInternal(id);onChange?.(id);};return[active,setActive]as const;}\n\nfunction moveFocus(e:React.KeyboardEvent<HTMLElement>,elements:HTMLElement[],current:number,onMove?:(index:number)=>void){let next=current;if(e.key===\"ArrowRight\"||e.key===\"ArrowDown\")next=(current+1)%elements.length;else if(e.key===\"ArrowLeft\"||e.key===\"ArrowUp\")next=(current-1+elements.length)%elements.length;else if(e.key===\"Home\")next=0;else if(e.key===\"End\")next=elements.length-1;else return;if(!elements.length)return;e.preventDefault();elements[next]?.focus();onMove?.(next);}\n\nfunction subscribeReducedMotion(onChange:()=>void){const query=window.matchMedia(\"(prefers-reduced-motion: reduce)\");query.addEventListener(\"change\",onChange);return()=>query.removeEventListener(\"change\",onChange);}\n\nfunction reducedMotionSnapshot(){return window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;}\n\nfunction serverReducedMotionSnapshot(){return false;}\n\nfunction useReducedMotion(){return React.useSyncExternalStore(subscribeReducedMotion,reducedMotionSnapshot,serverReducedMotionSnapshot);}\n\nexport interface GooeyTabItem {\n id:string;\n label:string;\n icon?:React.ReactNode;\n /** ID of the host's associated role=\"tabpanel\" element, when present. */\n panelId?:string;\n}\nconst DEFAULT_TABS:GooeyTabItem[]=[{id:\"home\",label:\"Home\",icon:<House size={18}/>},{id:\"explore\",label:\"Explore\",icon:<Compass size={18}/>},{id:\"saved\",label:\"Saved\",icon:<Heart size={18}/>},{id:\"profile\",label:\"Profile\",icon:<UserRound size={18}/>}];\nexport interface GooeyTabBarProps extends Omit<React.ComponentPropsWithoutRef<\"div\">,\"onChange\">{\n theme?:NavbarTheme;\n items?:GooeyTabItem[];\n value?:string;\n defaultValue?:string;\n onValueChange?:(value:string)=>void;\n showLabels?:boolean;\n gooey?:boolean;\n}\nexport function GooeyTabBar({theme=\"dark\",items=DEFAULT_TABS,value,defaultValue=\"home\",onValueChange,showLabels=true,gooey=true,className,style,...props}:GooeyTabBarProps){\n const[active,setActive]=useActive(value,defaultValue,onValueChange);const current=items.some(i=>i.id===active)?active:items[0]?.id;const reduce=useReducedMotion();const root=React.useRef<HTMLDivElement>(null);const uid=React.useId().replace(/:/g,\"\");const filterId=`gooey-tabs-${uid}`;const[bounds,setBounds]=React.useState({x:0,width:0,height:0});\n React.useEffect(()=>{const el=root.current;if(!el)return;const measure=()=>{const target=Array.from(el.querySelectorAll<HTMLButtonElement>('[role=\"tab\"]')).find(node=>node.dataset.value===current);if(!target)return;const next={x:target.offsetLeft,width:target.offsetWidth,height:target.offsetHeight};setBounds(old=>old.x===next.x&&old.width===next.width&&old.height===next.height?old:next);};const frame=requestAnimationFrame(measure);const observer=new ResizeObserver(measure);observer.observe(el);el.querySelectorAll('[role=\"tab\"]').forEach(tab=>observer.observe(tab));return()=>{cancelAnimationFrame(frame);observer.disconnect();};},[current,showLabels,items]);\n if(!items.length)return null;\n const radius=bounds.height*.34;\n return <div {...props} data-theme={theme} className={cn(\"@container w-full text-[color:var(--nav-ink)]\",className)} style={{...palette(theme),...style}}><svg aria-hidden=\"true\" width=\"0\" height=\"0\" className=\"pointer-events-none absolute\"><defs><filter id={filterId} x=\"-50%\" y=\"-100%\" width=\"200%\" height=\"300%\" colorInterpolationFilters=\"sRGB\"><feGaussianBlur in=\"SourceGraphic\" stdDeviation=\"7\" result=\"blur\"/><feColorMatrix in=\"blur\" mode=\"matrix\" values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 22 -8\" result=\"goo\"/><feComposite in=\"SourceGraphic\" in2=\"goo\" operator=\"atop\"/></filter></defs></svg><div className=\"mx-auto w-fit max-w-full overflow-x-auto rounded-full border border-[var(--nav-line)] bg-[var(--nav-panel)] p-1.5 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden\"><div ref={root} role=\"tablist\" aria-label={props[\"aria-label\"]??\"Main tabs\"} className=\"relative isolate flex min-w-fit gap-1\"><div aria-hidden=\"true\" className=\"pointer-events-none absolute inset-0 -z-10\" style={{filter:gooey&&!reduce?`url(#${filterId})`:undefined,opacity:bounds.width?1:0}}><motion.span initial={false} animate={{x:bounds.x,width:bounds.width,height:bounds.height}} transition={reduce?{duration:0}:{type:\"spring\",stiffness:430,damping:29,mass:.7}} className=\"absolute top-0 left-0 rounded-full bg-[var(--nav-ink)]\"/>{gooey&&!reduce&&<motion.span initial={false} animate={{x:bounds.x+bounds.width/2-radius,y:bounds.height/2-radius,width:radius*2,height:radius*2}} transition={{type:\"spring\",stiffness:180,damping:16,mass:.8}} className=\"absolute top-0 left-0 rounded-full bg-[var(--nav-ink)]\"/>}</div>{items.map((item,index)=><button key={item.id} type=\"button\" role=\"tab\" data-value={item.id} id={`tab-${uid}-${item.id}`} aria-label={item.label} aria-selected={current===item.id} aria-controls={item.panelId} tabIndex={current===item.id?0:-1} onClick={()=>setActive(item.id)} onKeyDown={e=>moveFocus(e,Array.from(root.current?.querySelectorAll<HTMLElement>('[role=\"tab\"]')??[]),index,next=>setActive(items[next].id))} className={cn(\"relative flex min-h-12 shrink-0 cursor-pointer items-center justify-center gap-2.5 rounded-full px-4 text-xs transition-colors duration-200\",current===item.id?\"text-[color:var(--nav-page)]\":muted,focus)}><span className=\"flex shrink-0 items-center\">{item.icon??<span aria-hidden=\"true\" className=\"text-[13px]\">{item.label.slice(0,1)}</span>}</span>{showLabels&&<span className={cn(\"whitespace-nowrap\",current!==item.id&&\"hidden @[440px]:inline\")}>{item.label}</span>}</button>)}</div></div></div>;\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}