Animated Menu
Animated menu with smooth transitions and content switching
Home
Home
Animated Menu
A beautiful, animated menu component with smooth transitions, content switching, and modern design patterns. Perfect for navigation, settings panels, or any interactive menu system.
Features
- Smooth Transitions: Fluid animations between menu states
- Content Switching: Dynamic content based on selected menu item
- Hover Effects: Interactive hover states with visual feedback
- Accessible: Full keyboard navigation and screen reader support
- Responsive: Adapts beautifully to all screen sizes
- Customizable: Easy to modify colors, animations, and content
Installation
npm install motion/react @tabler/icons-react
Basic Usage
import { AnimatedMenu } from "@/components/snippets/menu/Demo";const tabs = [{id: 1,label: "Home",icon: <IconHome className="h-4 w-4" />,content: <div>Home</div>,},{id: 2,label: "Projects",icon: <IconDeviceLaptop className="h-4 w-4" />,content: <div>Projects</div>,},{id: 3,label: "About",icon: <IconUser className="h-4 w-4" />,content: <div>About</div>,},{id: 4,label: "Contact",icon: <IconMail className="h-4 w-4" />,content: <div>Contact</div>,},];<AnimatedMenu tabs={tabs} />;
Props
Prop | Type | Default | Description |
---|---|---|---|
tabs | { id: number; label: string; icon?: React.ReactNode; content: React.ReactNode; }[] | - | Array of menu tab objects |
Examples
Basic Animated Menu
<AnimatedMenu tabs={tabs} />
Custom Styled Menu
<AnimatedMenutabs={tabs}className="bg-gradient-to-r from-purple-500 to-pink-500"/>
Best Practices
- Clear Labels: Use descriptive and concise menu labels
- Consistent Icons: Use consistent icon styles throughout
- Logical Grouping: Group related menu items together
- Keyboard Navigation: Ensure all items are accessible via keyboard
- Loading States: Show loading indicators for dynamic content
Accessibility
- ARIA Labels: Proper labels for screen readers
- Keyboard Navigation: Full keyboard support with arrow keys
- Focus Management: Clear focus indicators and management
- Semantic HTML: Proper HTML structure for accessibility
Performance Tips
- Lazy Loading: Load content only when menu items are selected
- Animation Optimization: Use
will-change
CSS property for better performance - Memoization: Memoize menu items to prevent unnecessary re-renders
- Debouncing: Debounce rapid menu changes to improve performance