We use cookies to ensure you get the best experience on our website. Read our privacy policy

Skip to main content

Directory

SideMenu Component

The SideMenu component creates smooth sliding panels that appear from either side of your screen. It’s perfect for mobile navigation, filters, or any secondary content that shouldn’t take up permanent screen space.

  • Check Circle

    Smooth Animations: Polished sliding transitions with backdrop blur

  • Check Circle

    Touch Support: Mobile-friendly interactions

  • Check Circle

    Accessibility: Full keyboard and screen reader support

Add a SideMenu with a trigger button:

<button id="menu-trigger">Open Menu</button>
<SideMenu side="left" triggerQuery="#menu-trigger">
<nav class="flex flex-col gap-4">
<a href="/home">Home</a>
<a href="/about">About</a>
<a href="/contact">Contact</a>
</nav>
</SideMenu>

In some cases you may want to close the menu when a button is clicked. By default the menu will not close when a button is clicked. You can do this by adding the data-close-side-menu attribute to the button.

const menu = await ready(document.querySelector('side-menu'));
menu.toggle(true); // Show menu
menu.toggle(false); // Hide menu
menu.toggle(); // Toggle menu
// Listen for menu open
menu.addEventListener(SideMenuEventNames.Open, (event) => {
const { id } = event.detail;
console.log('Menu opened:', id);
});
// Listen for menu close
menu.addEventListener(SideMenuEventNames.Close, (event) => {
const { id } = event.detail;
console.log('Menu closed:', id);
});
SideMenu Component Props Extends <div> HTMLElement
Prop Type Default Description
side 'left' | 'right' left Position of the menu
triggerQuery string Query selector for the trigger element

Limited Time Launch Sale

Build stunning websites faster with our AstroJS starter template. Get the SideMenu component and many more UI components ready to use in your next project.

GET 60% OFF!
North Star Themes Logo

Subscribe to our newsletter

Get the latest AstroJS tips and tricks right to your inbox

Email: [email protected]

© 2025 North Star Themes

Web Kit Provided By North Star Themes