Off-Canvas Slide In Navbar Template
Try this "off-canvas slide in" navbar. A very popular navbar style, especially for dashboards and mobile-first applications. Mobile-responsive and accessible. Copy and paste the code straight into your own web projects.

The Off-Canvas Slide-in Navbar
A modern and clean navigation pattern where the menu is hidden off-screen by default. Clicking a menu icon smoothly slides the navigation in from the side, pushing the main page content over to make space. This is a highly space-efficient and common pattern for web applications, dashboards, and mobile interfaces.
- "Push" Effect — The entire page content is smoothly pushed to the side when the menu opens, instead of the menu simply overlaying the content. This is achieved by transitioning a wrapper element.
- Advanced Accessibility (Focus Trapping) — When the menu is open, keyboard focus is "trapped" within it. Users can press Tab and Shift+Tab to cycle through the menu links without accidentally tabbing to the content behind the overlay. Pressing the Escape key will also close the menu.
- Overlay & Close Button: Includes a semi-transparent overlay that darkens the main content for better focus. Clicking the overlay or a dedicated "close" button will dismiss the menu.
- Pure CSS Transitions: The slide-in animations for the menu and page wrapper are handled with performant CSS
transform
transitions.
Coding Best Practices
- CSS custom properties (variables) are used for easy theme customization (colors, fonts).
- The code is appropriately commented to explain the purpose of each section.
- A tiny, efficient JavaScript snippet is used for the mobile menu toggle, as it is the most accessible and modern method (arguably superior to the older "checkbox hack").
Code
Here's the full code for the navbar template: