Skip to content
Esc
↑↓navigate↵open⌘Jpreview
On this page

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.

Show navigation groups inside the mobile menu panel.

gnostic ui
bunx --bun shadcn@latest add @gnostic/mobile-menu-1
npx shadcn@latest add @gnostic/mobile-menu-1
pnpm dlx shadcn@latest add @gnostic/mobile-menu-1

Open 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

PropType
navigationMobileMenuNavigationItem[]

Site links. Links with children open a nested drawer.

TypeMobileMenuNavigationItem[]
actions?MobileMenuButton[]

Action links displayed in the footer.

TypeMobileMenuButton[]
Default[]
title?string

Accessible title displayed in the main drawer.

Typestring
Default'Menu'
description?string

Supporting text. If omitted, will add a default description with `sr-only` class for screen readers.

Typestring
Default'Site navigation and actions.'
triggerLabel?string

Accessible name for the menu trigger.

Typestring
Default'Open menu'
navigationLabel?string

Accessible name for the main navigation.

Typestring
Default'Main navigation'
backLabel?string

Text for the control that returns to the parent menu.

Typestring
Default'Back'
overviewLabel?string

Text for the parent destination link in submenus that have an href.

Typestring
Default'Overview'
position?'bottom' | 'top' | 'left' | 'right'

Screen edge and swipe direction for every menu panel.

Type'bottom' | 'top' | 'left' | 'right'
Default'right'
variant?'default' | 'straight' | 'inset'

Popup style for every menu panel.

Type'default' | 'straight' | 'inset'
Default'default'
closeOnMedia?string

Media query that closes the menu and all open submenus.

Typestring
PropType
labelstring

Visible link text.

Typestring
hrefstring

Link destination.

Typestring
icon?BlockContentIcon

Optional icon name or imported icon component.

TypeBlockContentIcon
active?boolean

Mark the current page.

Typeboolean

MobileMenuNavigationItem

PropType
href?string

Destination. Omit it for a label that groups related items.

Typestring
links?MobileMenuNavigationItem[]

Child links. Each child can contain another level.

TypeMobileMenuNavigationItem[]
labelstring

Visible link text.

Typestring
icon?BlockContentIcon

Optional icon name or imported icon component.

TypeBlockContentIcon
active?boolean

Mark the current page.

Typeboolean

MobileMenuButton

PropType
variant?'default' | 'outline' | 'secondary' | 'ghost'

Button style.

Type'default' | 'outline' | 'secondary' | 'ghost'
Default'default'
labelstring

Visible link text.

Typestring
hrefstring

Link destination.

Typestring
icon?BlockContentIcon

Optional icon name or imported icon component.

TypeBlockContentIcon
active?boolean

Mark the current page.

Typeboolean

The 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.