Navigation Menu
Website navigation with dropdown panels: a few destinations each with an icon and one short line, and at most one featured card.
Ritla scan of this preview: 41 of 41 checks3 breakpointsScanned
Preview
Mirrored is the same English content laid out right to left: it separates a mirroring bug from a translation one.
Installation
Add the component
npx ritla add navigation-menuAlso works with shadcn:
npx shadcn@latest add @ritla/navigation-menuDependencies it brings
@base-ui/react@phosphor-icons/reactOr copy by hand
Installing by hand copies the component's source into your project. The source comes with a Ritla UI license, so the CLI is the short way to the same files.
Usage
import { NavigationMenu, NavigationMenuContent, NavigationMenuItem, NavigationMenuLink, NavigationMenuLinks, NavigationMenuList, NavigationMenuPanelLink, NavigationMenuTrigger,} from "@/components/ui/navigation-menu";<NavigationMenu aria-label="Main"> <NavigationMenuList> <NavigationMenuItem> <NavigationMenuTrigger>Products</NavigationMenuTrigger> <NavigationMenuContent> <NavigationMenuLinks> <NavigationMenuPanelLink href="/payments" icon={CreditCardIcon} title="Payments" description="Accept cards, Apple Pay and CliQ." /> </NavigationMenuLinks> </NavigationMenuContent> </NavigationMenuItem> <NavigationMenuItem> <NavigationMenuLink href="/pricing">Pricing</NavigationMenuLink> </NavigationMenuItem> </NavigationMenuList></NavigationMenu>Examples
One column, and the current page
columns={1} for short panels, with no featured card. The plain link for the current page takes active (aria-current="page").
On a dark surface
tone="inverse" on the root: white labels and a translucent white hover, for a row on a dark band, a photo or the brand color. The panel stays light. The panel also ends with a NavigationMenuFooter and its link, one per panel.
API reference
NavigationMenu
| Prop | Type | Default | Description |
|---|---|---|---|
aria-label | string | None | The navigation's name, when the page has more than one nav. |
delay / closeDelay | number | 50 / 50 | The wait before opening and closing on hover (ms). |
value / onValueChange | string | null | None | The open panel, to control it from code. |
tone | "default" | "inverse" | "default" | _Nav link's Tone, for the whole row. |
NavigationMenuTrigger
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | None | Figma's Label. The caret is added for you. |
NavigationMenuLink
| Prop | Type | Default | Description |
|---|---|---|---|
href | string | None | A plain link in the row, with no panel. |
active | boolean | None | The current page. |
render | ReactElement | None | Your framework's link, e.g. Next's <Link />. |
NavigationMenuLinks
| Prop | Type | Default | Description |
|---|---|---|---|
columns | 1 | 2 | 2 | Link columns, 220px each. |
NavigationMenuPanelLink
| Prop | Type | Default | Description |
|---|---|---|---|
icon | IconComponent | None | An icon in a brand/faint box. |
title | ReactNode | None | Figma's Title: the destination. |
description | ReactNode | None | Figma's Description: one short line. |
href / render | string / ReactElement | None | The link. |
NavigationMenuFeatured
| Prop | Type | Default | Description |
|---|---|---|---|
tag | ReactNode | None | The small tag at the top ("New"). |
title / description | ReactNode | None | Title and description. |
linkLabel | ReactNode | None | The call to action at the bottom; the whole card is the link. |
NavigationMenuFooter, NavigationMenuFooterLink
| Prop | Type | Default | Description |
|---|---|---|---|
link | ReactNode | None | A NavigationMenuFooterLink at the footer's start ("All products"), with an arrow that mirrors in Arabic. |
children | ReactNode | None | The help line at the footer's end; it may hold a link. |
href | string | None | NavigationMenuFooterLink: the destination. |
Usage guidelines
A navigation menu is a bar of links in a site header, some of which open panels. Links versus triggers, the panels, how it mirrors in Arabic, and the checks before handoff.
1. Links and triggers
A plain link goes to a page. A trigger opens a panel. Mixing both in one bar is fine; the chevron tells them apart.
Do
- Show a chevron only on triggers.
- Keep the active section marked with the Active state.
Don't
- Make a trigger also navigate on click.
- Use more than six items.
2. Panels
Panels align to the start edge of their trigger and never exceed the header width. On phones the same groups move into a side Sheet behind a menu button.
Do
- Use the
Header basevariants for desktop and mobile. - Group panel links in columns of five or fewer.
Don't
- Let a panel cover the hero.
- Animate panels longer than 150 ms.
3. Arabic and RTL
The link order mirrors and the panels align to the inline start of their trigger. The logo stays on the inline start.
Before handoff
- Desktop and mobile
Header baseplaced in both directions. - One panel open state shown.
- Active link marked on the current page.
Accessibility
Keyboard
Keys are written for left-to-right. In right-to-left the arrow keys swap: the one pointing toward the reading direction moves forward.
| Key | Action |
|---|---|
| Tab | Along the row; from an open trigger through its panel's links, then on to the next item. |
| EnterSpace | On a trigger: opens or closes its panel. |
| ArrowRightArrowLeft | Along the row; in Arabic, ArrowLeft goes to the next. |
| Esc | Closes the panel and returns focus to its trigger. |
ARIA
- A
<nav>with a list (ul) of items; each trigger hasaria-expandedandaria-controls. - Panel links are real links, and the featured card is one link.
- Triggers are 32px tall with a 48px hit area vertically only.
- On phones: a menu button that opens a Drawer with the same groups in an Accordion.
Arabic and RTL notes
Mirrors
- The first item sits on the right, and the panel starts at the row's right edge.
- Panel links read from the right, and the featured card sits on the left.
- In the footer the link sits on the right with its arrow pointing left, and the help line on the left.
Does not mirror
- The trigger's caret points down and turns when open; it doesn't mirror.
- The links' icons don't mirror.
- Numerals
- Numbers in descriptions follow the numerals setting (
toNumeralsfor fixed strings). - Arabic typography
- Triggers
label-16Medium (Semibold while their panel is open), link titleslabel-14Semibold, descriptionslabel-12, the card titlelabel-16Semibold. - Mixed-direction text
- Latin product names (Apple Pay, iOS) inside an Arabic description keep their order. The panel carries the page's direction and language into the portal.
Do
- Set
Nav positionto Start or Center as in English; it mirrors on its own. - Check long Arabic labels at the tablet width.
Don't
- Centre the links to dodge RTL.
- Mirror chevrons that point down.
Checks it passes
The Ritla checks this component satisfies by construction. Used as documented, it does not bring these defects onto your page.
- Clipped text: content wider than its box with overflow hidden and no ellipsis
- Fixed-pixel-width container whose Arabic text exceeds the space
- Arabic text falling back past the declared font family (measured, declared, or a webfont that failed to load)
- letter-spacing applied to Arabic text (breaks the connected script)
- flex row-reverse faking RTL instead of dir (tab order fights visual order)