Mobile Menu Blocks for Astro
Astro mobile navigation with nested drawer panels and swipe gestures.
This block uses the Drawer component. Items with child
links open a new drawer panel. Child links can contain more submenus. Swipe,
press Escape, or select Back to return one level. Selecting a destination
closes the full menu. A parent with an href keeps its destination under Overview.
Omit href when a parent only groups related items. Its submenu uses
DrawerMenuGroup label to show a styled group label instead of an Overview link.
The footer contains the actions and the default slot.
Navigation
Show navigation groups inside the mobile menu panel.
bunx --bun shadcn@latest add @gnostic/mobile-menu-1npx shadcn@latest add @gnostic/mobile-menu-1pnpm dlx shadcn@latest add @gnostic/mobile-menu-1Open Components, then Navigation to try two submenu levels. Components has an
Overview link. Navigation has no destination and uses a group label. Each panel opens
from the same edge. The default is the right edge; set position="bottom"
to use bottom panels with swipe handles.
Installation
bunx --bun shadcn@latest add @gnostic/mobile-menu-1
Header option
All five header blocks accept mobileMenu="drawer".
They use the same navigation data and pass actions, plus
slot="mobile", to this block. The default remains mobileMenu="sheet".
<HeaderBlock
logo={logo}
navigation={navigation}
actions={actions}
mobileMenu="drawer"
>
<a slot="mobile" href="/support">Support</a>
</HeaderBlock>
The header hides the trigger at 1024px and closes an open drawer at that width.
Props
MobileMenuProps
navigationMobileMenuNavigationItem[]
Site links. Links with children open a nested drawer.
MobileMenuNavigationItem[]actions?MobileMenuButton[]
Action links displayed in the footer.
MobileMenuButton[][]title?string
Accessible title displayed in the main drawer.
string'Menu'description?string
Supporting text. If omitted, will add a default description with `sr-only` class for screen readers.
string'Site navigation and actions.'triggerLabel?string
Accessible name for the menu trigger.
string'Open menu'navigationLabel?string
Accessible name for the main navigation.
string'Main navigation'backLabel?string
Text for the control that returns to the parent menu.
string'Back'overviewLabel?string
Text for the parent destination link in submenus that have an href.
string'Overview'position?'bottom' | 'top' | 'left' | 'right'
Screen edge and swipe direction for every menu panel.
'bottom' | 'top' | 'left' | 'right''right'variant?'default' | 'straight' | 'inset'
Popup style for every menu panel.
'default' | 'straight' | 'inset''default'closeOnMedia?string
Media query that closes the menu and all open submenus.
stringMobileMenuLink
labelstring
Visible link text.
stringhrefstring
Link destination.
stringicon?BlockContentIcon
Optional icon name or imported icon component.
BlockContentIconactive?boolean
Mark the current page.
booleanMobileMenuNavigationItem
href?string
Destination. Omit it for a label that groups related items.
stringlinks?MobileMenuNavigationItem[]
Child links. Each child can contain another level.
MobileMenuNavigationItem[]labelstring
Visible link text.
stringicon?BlockContentIcon
Optional icon name or imported icon component.
BlockContentIconactive?boolean
Mark the current page.
booleanMobileMenuButton
variant?'default' | 'outline' | 'secondary' | 'ghost'
Button style.
'default' | 'outline' | 'secondary' | 'ghost''default'labelstring
Visible link text.
stringhrefstring
Link destination.
stringicon?BlockContentIcon
Optional icon name or imported icon component.
BlockContentIconactive?boolean
Mark the current page.
booleanThe standalone block has no breakpoint restriction. Use class="lg:hidden"
and closeOnMedia="(min-width: 1024px)" when you pair it with desktop navigation.
Custom footer links can use DrawerClose as="a" to close on selection.
Use class={buttonVariants()} when that control should look like a button.
Choose a mobile menu layout
Choose a mobile menu for navigation that does not fit the desktop header at smaller widths. Keep its destinations aligned with the desktop navigation.
Pass content from Astro
Pass navigation groups, optional actions, and trigger/title labels. Position and variant props change the panel layout. Use closeOnMedia where supported to close a panel when the page returns to a desktop layout.
Responsive layout and images
Test opening, Escape, link activation, and focus return with a keyboard. A menu with many links needs scrolling that leaves the close control reachable. Logo or icon artwork needs a text name when it is the only visible mark.
Compose the next section
Use Header for the complete shell and Sheet or Drawer for lower-level panel composition.