Navigation Menu
Top-level site navigation with panels of links.
When to use
- The top-level navigation of a site, with panels of links under some items.
- A marketing or docs site with a few sections, each with a handful of pages.
When not to use
- App navigation with many sections: use Sidebar.
- A list of actions: use Dropdown Menu, or Menubar for a desktop-style app.
- A trail back up the hierarchy: use Breadcrumb.
Install
npx shadcn@latest add @clinia/navigation-menuClinia rules
- Set
activeon the current section's link. It setsaria-current="page". - Top-level labels are short nouns:
Product,Docs,Pricing. Keep the bar to about five items. - A trigger only opens its panel. Put the section's own page as the first link inside the panel.
- Panel links pair a title with one line of
text-muted-foregroundthat says what's there.
Do and don't
Accessibility
Built in
- The current page's link is tinted
bg-accent/15. Setactiveon it, which also setsaria-current. - Triggers expose
aria-expanded. Escape closes the open panel and returns focus to its trigger.
Your responsibility
- Set
activeon the link to the current page, so it's marked for screen readers too. - Give every panel link text. An image or an icon alone names nothing.
How to test
- Press Tab to reach a trigger, then Enter: its panel opens and the trigger reads as expanded.
- Press Tab again: focus moves into the panel's links.
- Press Escape: the panel closes and focus returns to the trigger.
- With a screen reader, the active link is announced as the current page.
API
Every prop comes from Base UI Navigation Menu.
Related