UI.MD

Site Nav

The phone menu a SiteHeader's links fold into on a small screen: a panel with the brand, the main links, quieter links and the account.

Installation

$
npx shadcn@latest add https://ui.mattdowney.com/r/site-nav.json

Usage

import { SiteNav, siteNavItemClass, siteNavItemActiveClass, siteNavUtilityItemClass } from "@/components/ui/site-nav"

Examples

Default

You own the open state and the trigger, usually a HeaderIconButton shown only below md. Style your own router links with the exported classes; the current page takes siteNavItemActiveClass in place of the plain one.

API Reference

PropTypeDefaultDescription
openboolean-Whether the panel is open. Required: the trigger lives in your header, so you hold the state.
onOpenChange(open: boolean) => void-Called when the panel opens or closes, including on Escape and a backdrop tap.
brandReactNode-Your logo at the top of the panel, so it names itself once open.
navReactNode-The main links, styled with siteNavItemClass (44px tall, for a thumb).
utilityReactNode-Quieter links (docs, feedback, legal), styled with siteNavUtilityItemClass.
accountReactNode-Sign in or the account link. Keep the main sign-up action in the header bar, not here.
classNamestring-Extra classes on the panel.
openbooleanWhether the panel is open. Required: the trigger lives in your header, so you hold the state.
onOpenChange(open: boolean) => voidCalled when the panel opens or closes, including on Escape and a backdrop tap.
brandReactNodeYour logo at the top of the panel, so it names itself once open.
navReactNodeThe main links, styled with siteNavItemClass (44px tall, for a thumb).
utilityReactNodeQuieter links (docs, feedback, legal), styled with siteNavUtilityItemClass.
accountReactNodeSign in or the account link. Keep the main sign-up action in the header bar, not here.
classNamestringExtra classes on the panel.