Mobile Navigation Drawer
nswds-ui/mobile-navFreeBlock
Hamburger trigger opening a left-side sheet containing the multi-level push menu — the mobile navigation pattern for NSW site headers.
Install it
npx shadcn@latest add https://raw.githubusercontent.com/digitalnsw/nswds-ui/main/apps/registry/public/r/mobile-nav.jsonSource
1'use client'23import * as React from 'react'45import { Button } from '@/components/button'6import { PushMenu, type PushMenuItem } from '@/components/push-menu'7import { Sheet, SheetContent, SheetTitle, SheetTrigger } from '@/components/sheet'8import { IconMenu } from '@/icons/menu'910export type MobileNavProps = {11 /** The menu tree, passed straight to `PushMenu`. Item ids must be unique. */12 navigation: PushMenuItem[]13 /**14 * The app's current pathname. Leaf links whose `href` matches get15 * `aria-current="page"` and the active treatment (see `PushMenu`).16 */17 currentHref?: string18 /**19 * Drawer title: names the dialog for assistive tech (via a visually-hidden20 * `SheetTitle`) and is shown by `PushMenu` as its root level heading.21 * Defaults to `"Menu"`.22 */23 title?: string24 /** Controlled open state. Leave unset for uncontrolled. */25 open?: boolean26 /** Initial open state when uncontrolled. Defaults to `false`. */27 defaultOpen?: boolean28 /**29 * Fired whenever the drawer opens or closes — trigger click, Escape,30 * backdrop click, the menu's own close button, and leaf-link clicks all31 * funnel through here. Pair with `open` for a controlled drawer.32 */33 onOpenChange?: (open: boolean) => void34 /** Extra drawer content rendered below the menu — a sign-in link, say. */35 children?: React.ReactNode36}3738/**39 * Mobile navigation drawer: a hamburger button that opens a left-side sheet40 * containing the multi-level `PushMenu`. A registry block — copy the source41 * and adapt it — composed entirely from published components: `Button`42 * (trigger), `Sheet` (the drawer, on the Base UI dialog primitive) and43 * `PushMenu` (the drill-down menu).44 *45 * Accessibility contract:46 *47 * - Base UI's dialog provides the modal behaviour — focus trap, scroll lock,48 * Escape and backdrop dismissal, and focus return to the trigger on close.49 * Nothing is hand-rolled (the nswds-app source hand-assembled this from50 * Headless UI Dialog + fixed-position divs).51 * - The dialog's accessible name comes from a visually-hidden `SheetTitle`.52 * It is `sr-only` because `PushMenu` already renders a visible title in its53 * header row: a second visible "Menu" heading would duplicate it, but the54 * per-level heading can't name the dialog either — it changes as the user55 * drills, and it isn't wired to the popup's `aria-labelledby`. Same56 * arrangement as sidebar-style sheets elsewhere in the shadcn ecosystem.57// … truncated
What it pulls in
Other registry items
Files it writes
More from @nswds/ui
All 46 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Footer — Collapsible Site Mapfooter-accordion | @nswds/ui | Blocks | Free | no deps | |
| Footer — Compact Barfooter-compact | @nswds/ui | Blocks | Free | no deps | |
| Footer — Contact Detailsfooter-contact | @nswds/ui | Blocks | Free | no deps | |
| Footer — Call to Actionfooter-cta | @nswds/ui | Blocks | Free | no deps | |
| Footer — Newsletterfooter-newsletter | @nswds/ui | Blocks | Free | no deps | |
| Footer — Simple Centredfooter-simple-centred | @nswds/ui | Blocks | Free | no deps | |
| Footer — Site Mapfooter-sitemap | @nswds/ui | Blocks | Free | no deps | |
| Footer — Site Map with Brandfooter-sitemap-brand | @nswds/ui | Blocks | Free | no deps |
