Sliding Menu
A modern sliding menu with smooth animations, customizable directions, and responsive design. Perfect for mobile-first applications and space-efficient navigation.
Responsive Design
Yes
Dark Mode Support
No
lines
1115
Browser Compatibility
No
Live Preview
Interact with the component without leaving the page.
Sliding Menu
A modern and versatile sliding menu component with multiple animation directions, customizable styles, and responsive design. Perfect for mobile-first applications and space-efficient navigation systems.
Features
- Multiple Directions: Slide from left, right, top, or bottom
- Animation Styles: Overlay, push, and reveal animations
- Mobile Optimized: Touch-friendly interactions and responsive design
- Smooth Animations: Hardware-accelerated CSS transitions
- Keyboard Navigation: Full keyboard accessibility support
- User Profile: Integrated user information display
- Quick Actions: Convenient action buttons in menu footer
- Status Indicators: Real-time menu state information
- Customizable: Easy to modify colors, sizes, and behaviors
Key Components
Menu Structure
- Header: User profile with avatar and close button
- Navigation: Main menu items with icons and badges
- Footer: Quick actions and logout functionality
- Overlay: Semi-transparent background overlay
Animation Directions
- Left: Slides in from the left side (default)
- Right: Slides in from the right side
- Top: Slides down from the top
- Bottom: Slides up from the bottom
Animation Styles
- Overlay: Menu appears over content
- Push: Menu pushes content to the side
- Reveal: Content slides to reveal menu underneath
Menu Items
Navigation Links
- Home: Main dashboard with βNewβ badge
- Dashboard: Analytics and overview
- Users: User management with count indicator
- Projects: Project management
- Analytics: Data and reports
- Messages: Communication with unread count
- Calendar: Schedule and events
- Settings: Application preferences
Quick Actions
- New Project: Create new project
- Export Data: Download data exports
- Logout: Sign out of application
Interactive Features
Menu Controls
- Hamburger Button: Animated three-line menu trigger
- Close Button: X button in menu header
- Overlay Click: Click outside to close
- Keyboard Shortcuts: ESC to close, arrows to navigate
Visual Feedback
- Active States: Highlighted current page
- Hover Effects: Smooth color transitions
- Loading States: Animated indicators
- Status Display: Real-time menu information
Responsive Design
Mobile Features
- Touch Gestures: Swipe to open/close
- Optimized Sizing: Appropriate button and text sizes
- Reduced Width: Narrower menu on small screens
- Auto-close: Menu closes after navigation on mobile
Desktop Features
- Hover Interactions: Enhanced hover states
- Keyboard Navigation: Full arrow key support
- Larger Touch Targets: Comfortable click areas
- Multi-column Layout: Efficient space usage
Accessibility Features
ARIA Support
role="navigation"for menu containeraria-labelfor descriptive button labelsaria-expandedfor menu state indication- Proper heading hierarchy
Keyboard Navigation
- Tab: Navigate through interactive elements
- Arrow Keys: Move between menu items
- Enter/Space: Activate menu items
- Escape: Close menu and return focus
Focus Management
- Visible focus indicators
- Focus trapping within open menu
- Logical tab order
- Return focus to trigger on close
Animation Details
CSS Transforms
translateX()for horizontal slidingtranslateY()for vertical sliding- Hardware acceleration with
will-change - Smooth 300ms transitions
Animation Timing
- Open: 300ms ease-out
- Close: 300ms ease-in
- Hover: 150ms ease
- Focus: Instant for accessibility
Customization Options
Visual Customization
- Colors: Primary, secondary, and accent colors
- Typography: Font families and sizes
- Spacing: Padding and margin adjustments
- Shadows: Box shadow variations
- Borders: Border radius and colors
Behavioral Customization
- Animation Speed: Transition duration
- Menu Width: Horizontal menu dimensions
- Menu Height: Vertical menu dimensions
- Overlay Opacity: Background transparency
- Auto-close: Automatic menu closing behavior
Menu Content
User Profile Section
- Avatar: User profile image or icon
- Name: Userβs display name
- Email: Userβs email address
- Status: Online/offline indicator
Navigation Section
- Icons: Emoji or icon font icons
- Labels: Clear, descriptive text
- Badges: Notification indicators
- Counters: Numeric status indicators
Footer Section
- Quick Actions: Frequently used functions
- Settings: Application preferences
- Logout: Secure sign-out option
Performance Considerations
- CSS Transforms: Hardware-accelerated animations
- Event Delegation: Efficient event handling
- Debounced Resize: Optimized window resize handling
- Minimal Reflows: Efficient DOM manipulation
- Lazy Loading: On-demand content loading
Browser Compatibility
Supports all modern browsers:
- Chrome 60+
- Firefox 55+
- Safari 12+
- Edge 79+
- Mobile browsers with touch support
Usage Tips
- Keep Menu Items Focused: Limit to essential navigation
- Use Clear Icons: Recognizable and consistent iconography
- Provide Visual Feedback: Show current page and interactions
- Test on Mobile: Ensure touch-friendly interactions
- Consider Menu Width: Balance content and screen space
- Implement Proper Focus: Ensure keyboard accessibility
- Use Semantic HTML: Proper markup for screen readers
Advanced Features
Gesture Support
- Swipe gestures for mobile devices
- Touch start/end event handling
- Momentum scrolling within menu
State Management
- Menu open/close state persistence
- User preference storage
- Dynamic menu content updates
Integration Options
- Router integration for navigation
- State management library support
- API-driven menu content
- Theme switching capabilities
HTML
189
lines
CSS
631
lines
JavaScript
295
lines
<div class="sliding-menu-demo">
<div class="demo-content">
<h2>Sliding Menu Demo</h2>
<p>A versatile sliding menu component with multiple animation directions, overlay options, and responsive behavior. Ideal for mobile applications and modern web interfaces.</p>
<div class="demo-controls">
<h3>Menu Options:</h3>
<div class="control-group">
<div class="control-section">
<label>Direction:</label>
<div class="control-buttons">
<button class="control-btn active" data-direction="left">Left</button>
<button class="control-btn" data-direction="right">Right</button>
<button class="control-btn" data-direction="top">Top</button>
<button class="control-btn" data-direction="bottom">Bottom</button>
</div>
</div>
<div class="control-section">
<label>Style:</label>
<div class="control-buttons">
<button class="style-btn active" data-style="overlay">Overlay</button>
<button class="style-btn" data-style="push">Push</button>
<button class="style-btn" data-style="reveal">Reveal</button>
</div>
</div>
</div>
</div>
</div>
<div class="menu-container">
<div class="app-header">
<button class="menu-trigger" aria-label="Toggle menu">
<span class="hamburger-icon">
<span class="line"></span>
<span class="line"></span>
<span class="line"></span>
</span>
</button>
<h1 class="app-title">Sliding Menu App</h1>
<div class="header-actions">
<button class="action-btn" aria-label="Search">
<span class="icon">π</span>
</button>
<button class="action-btn" aria-label="Notifications">
<span class="icon">π</span>
<span class="badge">3</span>
</button>
</div>
</div>
<div class="main-content">
<div class="content-section">
<h2>Welcome to the App</h2>
<p>This is the main content area. Click the menu button to open the sliding menu from different directions.</p>
<div class="feature-cards">
<div class="feature-card">
<div class="card-icon">π±</div>
<h3>Mobile First</h3>
<p>Optimized for mobile devices with touch-friendly interactions.</p>
</div>
<div class="feature-card">
<div class="card-icon">π¨</div>
<h3>Customizable</h3>
<p>Multiple animation styles and directions to choose from.</p>
</div>
<div class="feature-card">
<div class="card-icon">β‘</div>
<h3>Smooth</h3>
<p>Hardware-accelerated animations for optimal performance.</p>
</div>
</div>
</div>
</div>
<div class="sliding-menu left-menu overlay-style" role="navigation" aria-label="Main navigation">
<div class="menu-header">
<div class="user-profile">
<div class="avatar">π€</div>
<div class="user-info">
<div class="user-name">John Doe</div>
<div class="user-email">john@example.com</div>
</div>
</div>
<button class="menu-close" aria-label="Close menu">
<span class="close-icon">β</span>
</button>
</div>
<div class="menu-content">
<nav class="menu-nav">
<ul class="menu-list">
<li class="menu-item">
<a href="#" class="menu-link active">
<span class="menu-icon">π </span>
<span class="menu-text">Home</span>
<span class="menu-badge">New</span>
</a>
</li>
<li class="menu-item">
<a href="#" class="menu-link">
<span class="menu-icon">π</span>
<span class="menu-text">Dashboard</span>
</a>
</li>
<li class="menu-item">
<a href="#" class="menu-link">
<span class="menu-icon">π₯</span>
<span class="menu-text">Users</span>
<span class="menu-count">24</span>
</a>
</li>
<li class="menu-item">
<a href="#" class="menu-link">
<span class="menu-icon">π</span>
<span class="menu-text">Projects</span>
</a>
</li>
<li class="menu-item">
<a href="#" class="menu-link">
<span class="menu-icon">π</span>
<span class="menu-text">Analytics</span>
</a>
</li>
<li class="menu-item">
<a href="#" class="menu-link">
<span class="menu-icon">π¬</span>
<span class="menu-text">Messages</span>
<span class="menu-count">5</span>
</a>
</li>
<li class="menu-item">
<a href="#" class="menu-link">
<span class="menu-icon">π
</span>
<span class="menu-text">Calendar</span>
</a>
</li>
<li class="menu-item">
<a href="#" class="menu-link">
<span class="menu-icon">βοΈ</span>
<span class="menu-text">Settings</span>
</a>
</li>
</ul>
</nav>
<div class="menu-footer">
<div class="menu-section">
<h4 class="section-title">Quick Actions</h4>
<div class="quick-actions">
<button class="quick-action">
<span class="action-icon">β</span>
<span class="action-text">New Project</span>
</button>
<button class="quick-action">
<span class="action-icon">π€</span>
<span class="action-text">Export Data</span>
</button>
</div>
</div>
<div class="menu-section">
<button class="logout-btn">
<span class="logout-icon">πͺ</span>
<span class="logout-text">Logout</span>
</button>
</div>
</div>
</div>
</div>
<div class="menu-overlay"></div>
<div class="menu-status">
<div class="status-item">
<span class="status-label">Direction:</span>
<span class="status-value" id="currentDirection">Left</span>
</div>
<div class="status-item">
<span class="status-label">Style:</span>
<span class="status-value" id="currentStyle">Overlay</span>
</div>
<div class="status-item">
<span class="status-label">Status:</span>
<span class="status-value" id="menuStatus">Closed</span>
</div>
</div>
</div>
</div>