{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "floating-navbar", "type": "registry:ui", "title": "Floating Navbar", "description": "A floating navigation bar that appears on scroll with smooth animations.", "dependencies": [ "motion", "lucide-react" ], "files": [ { "path": "registry/ruixenui/floating-navbar.tsx", "content": "\"use client\";\n\nimport React, { useState, useRef, useEffect } from \"react\";\nimport { motion } from \"motion/react\";\nimport { Home, Search, Bell, User, Settings, Bookmark } from \"lucide-react\";\n\nconst FloatingNav = () => {\n const [active, setActive] = useState(0);\n const [indicatorStyle, setIndicatorStyle] = useState({ width: 0, left: 0 });\n const containerRef = useRef(null);\n const btnRefs = useRef<(HTMLButtonElement | null)[]>([]);\n\n const items = [\n { id: 0, icon: , label: \"Home\" },\n { id: 1, icon: , label: \"Search\" },\n { id: 2, icon: , label: \"Alerts\" },\n { id: 3, icon: , label: \"Profile\" },\n { id: 4, icon: , label: \"Saved\" },\n { id: 5, icon: , label: \"Profile\" },\n { id: 6, icon: , label: \"Settings\" },\n ];\n\n // Update indicator position when active changes or resize\n useEffect(() => {\n const updateIndicator = () => {\n if (btnRefs.current[active] && containerRef.current) {\n const btn = btnRefs.current[active];\n const container = containerRef.current;\n if (!btn) return;\n const btnRect = btn.getBoundingClientRect();\n const containerRect = container.getBoundingClientRect();\n\n setIndicatorStyle({\n width: btnRect.width,\n left: btnRect.left - containerRect.left,\n });\n }\n };\n\n updateIndicator();\n window.addEventListener(\"resize\", updateIndicator);\n return () => window.removeEventListener(\"resize\", updateIndicator);\n }, [active]);\n\n return (\n
\n \n {items.map((item, index) => (\n (btnRefs.current[index] = el)}\n onClick={() => setActive(index)}\n className=\"relative flex flex-col items-center justify-center flex-1 px-2 py-2 text-sm font-medium text-gray-600 dark:text-gray-300\"\n >\n
{item.icon}
\n {/* hide labels on small screens */}\n \n \n ))}\n\n {/* Sliding Active Indicator */}\n \n
\n \n );\n};\n\nexport default FloatingNav;\n", "type": "registry:ui", "target": "components/ruixen/floating-navbar.tsx" } ] }