Please use Desktop to view and interact with components
Components300msspring
Animated Navbar
Navigation bar with animated underline indicator
navigationnavbarmenutabs
Useto navigate between components
Preview
Code
TypeScript + React
'use client'
import { useState } from 'react'
import { motion } from 'framer-motion'
const navItems = ['Home', 'About', 'Services', 'Contact']
export function AnimatedNavbar() {
const [activeIndex, setActiveIndex] = useState(0)
return (
<nav className="rounded-2xl border bg-[var(--card-bg)] p-2">
<ul className="flex gap-1">
{navItems.map((item, index) => (
<li key={item} className="relative">
<motion.button
onClick={() => setActiveIndex(index)}
className="relative z-10 px-4 py-2 text-sm font-medium transition-colors"
style={{
color: activeIndex === index ? 'white' : 'var(--foreground)',
}}
whileHover={{ scale: 1.05 }}
whileTap={{ scale: 0.95 }}
>
{item}
</motion.button>
{activeIndex === index && (
<motion.div
layoutId="navbar-indicator"
className="absolute inset-0 rounded-lg bg-accent"
transition={{
type: 'spring',
stiffness: 380,
damping: 30,
}}
/>
)}
</li>
))}
</ul>
</nav>
)
}
How to Use
- 1Install Framer Motion:
npm install framer-motion - 2Copy the code from above
- 3Paste it into your project and customize as needed
- 4Colors are customizable via Tailwind CSS classes. The default theme uses dark mode colors defined in your globals.css file