# NavigationMenu Navigate between pages with links and groups of related destinations. [Interactive guide](/docs/components/navigationmenu) · Forge 3.2.0 Use the API for your installed version. Run `npx --no-install wss3-forge api --json` inside the project. ## Implementation guidance ### When to use it Use NavigationMenu for a group of navigational links and direct destinations. Use Navbar for the complete site header. ### How to compose it Give the navigation landmark a name and mark the active page with aria-current. Connect each link through the selected backend's router composition. ### What to verify Reach a direct link and a submenu destination using the keyboard. Verify Escape returns focus to its trigger and the current page is announced. ## Usage ```tsx import { NavigationMenu, NavigationMenuContent, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger } from 'wss3-forge/base-ui' ``` - Use a named navigation landmark. Each trigger reveals links to related pages. Escape closes its panel and returns focus to the trigger. - A top-level destination can be a direct NavigationMenuLink. Mark the current page with active and aria-current="page". - Compose your router link with the Base UI render prop or the Radix asChild prop. The React Router example requires a router provider. - The root package also accepts an items array and an optional renderLink callback. Use Navbar when you need the complete site header. ## Guide ### Composition Place each destination in its own list item. A group pairs a trigger with a panel of links. ```tsx NavigationMenu NavigationMenuList NavigationMenuItem NavigationMenuTrigger NavigationMenuContent NavigationMenuLink NavigationMenuItem NavigationMenuLink NavigationMenuIndicator (optional) ``` ### Link component Compose a link with render in Base UI or asChild in Radix. Apply the trigger style to a top-level destination. ```tsx // Base UI } className={navigationMenuTriggerStyle()}> Documentation // Radix Documentation ``` ## Runnable examples ### Navigation menu ```tsx import { useState, type MouseEvent, type ReactNode } from 'react' import { Link as RouterLink } from 'react-router-dom' import { Circle16Regular, CheckmarkCircle16Regular, Info16Regular } from '@fluentui/react-icons' import { VStack, HStack, Text, useMediaQuery } from 'wss3-forge' import { DirectionProvider, NavigationMenu, NavigationMenuList, NavigationMenuItem, NavigationMenuTrigger, NavigationMenuContent, NavigationMenuLink, navigationMenuTriggerStyle } from 'wss3-forge/base-ui' function NavigationExample({ rtl = false }: { rtl?: boolean }) { const [destination, setDestination] = useState('') function selectDestination(event: MouseEvent) { event.preventDefault() setDestination(event.currentTarget.search || event.currentTarget.pathname) } const desktop = useMediaQuery('(min-width: 768px)') const wide = useMediaQuery('(min-width: 1024px)') const t = (english: string, arabic: string) => rtl ? arabic : english const link = (title: string, href: string, description: string) =>
  • }>{title}{description}
  • const group = (name: string, contents: ReactNode) => {name} {contents} const listStyle = { listStyle: 'none', margin: 0, padding: 0, maxWidth: 'calc(100vw - 2rem)' } return {group(t('Getting started', 'البدء'), {link(t('Introduction', 'مقدمة'), '/docs', t('Get to know Forge components and design tokens.', 'تعرّف على مكونات Forge ورموز التصميم.'))} {link(t('Installation', 'التثبيت'), '/docs/installation', t('Install the package and configure your provider.', 'ثبّت الحزمة واضبط المزوّد.'))} {link(t('Typography', 'الطباعة'), '/docs/components/typography', t('Text styles for your headings and paragraphs.', 'أنماط النص للعناوين والفقرات.'))} )} {desktop && group(t('Components', 'المكونات'), {link(t('Alert Dialog', 'مربع التنبيه'), '/docs/components/alert-dialog', t('Request a decision before continuing.', 'اطلب قراراً قبل المتابعة.'))} {link(t('Hover Card', 'بطاقة التمرير'), '/docs/components/hover-card', t('Preview the content behind a link.', 'اعرض معاينة لمحتوى الرابط.'))} {link(t('Progress', 'التقدم'), '/docs/components/progress', t('Show progress toward completion.', 'اعرض التقدم نحو الاكتمال.'))} {link(t('Scroll Area', 'منطقة التمرير'), '/docs/components/scroll-area', t('Browse content inside a bounded area.', 'تصفّح المحتوى داخل مساحة محدودة.'))} {link(t('Tabs', 'علامات التبويب'), '/docs/components/tabs', t('Switch between related panels.', 'تنقّل بين اللوحات ذات الصلة.'))} {link(t('Tooltip', 'تلميح'), '/docs/components/tooltip', t('Explain a control on focus or hover.', 'اشرح الزر عند التركيز أو التمرير.'))} )} {group(t('With Icon', 'مع أيقونة'), {[ { title: t('Backlog', 'المهام المتراكمة'), icon: , href: '?status=backlog' }, { title: t('To Do', 'قيد الانتظار'), icon: , href: '?status=todo' }, { title: t('Done', 'مكتمل'), icon: , href: '?status=done' }, ].map(item =>
  • }> {item.icon}{item.title}
  • )}
    )} } className={navigationMenuTriggerStyle()} active={destination === '/docs'}>{t('Docs', 'الوثائق')}
    } export default function Example() { return () } ``` ### RTL ```tsx import { useState, type MouseEvent, type ReactNode } from 'react' import { Link as RouterLink } from 'react-router-dom' import { Circle16Regular, CheckmarkCircle16Regular, Info16Regular } from '@fluentui/react-icons' import { VStack, HStack, Text, useMediaQuery } from 'wss3-forge' import { DirectionProvider, NavigationMenu, NavigationMenuList, NavigationMenuItem, NavigationMenuTrigger, NavigationMenuContent, NavigationMenuLink, navigationMenuTriggerStyle } from 'wss3-forge/base-ui' function NavigationExample({ rtl = false }: { rtl?: boolean }) { const [destination, setDestination] = useState('') function selectDestination(event: MouseEvent) { event.preventDefault() setDestination(event.currentTarget.search || event.currentTarget.pathname) } const desktop = useMediaQuery('(min-width: 768px)') const wide = useMediaQuery('(min-width: 1024px)') const t = (english: string, arabic: string) => rtl ? arabic : english const link = (title: string, href: string, description: string) =>
  • }>{title}{description}
  • const group = (name: string, contents: ReactNode) => {name} {contents} const listStyle = { listStyle: 'none', margin: 0, padding: 0, maxWidth: 'calc(100vw - 2rem)' } return {group(t('Getting started', 'البدء'), {link(t('Introduction', 'مقدمة'), '/docs', t('Get to know Forge components and design tokens.', 'تعرّف على مكونات Forge ورموز التصميم.'))} {link(t('Installation', 'التثبيت'), '/docs/installation', t('Install the package and configure your provider.', 'ثبّت الحزمة واضبط المزوّد.'))} {link(t('Typography', 'الطباعة'), '/docs/components/typography', t('Text styles for your headings and paragraphs.', 'أنماط النص للعناوين والفقرات.'))} )} {desktop && group(t('Components', 'المكونات'), {link(t('Alert Dialog', 'مربع التنبيه'), '/docs/components/alert-dialog', t('Request a decision before continuing.', 'اطلب قراراً قبل المتابعة.'))} {link(t('Hover Card', 'بطاقة التمرير'), '/docs/components/hover-card', t('Preview the content behind a link.', 'اعرض معاينة لمحتوى الرابط.'))} {link(t('Progress', 'التقدم'), '/docs/components/progress', t('Show progress toward completion.', 'اعرض التقدم نحو الاكتمال.'))} {link(t('Scroll Area', 'منطقة التمرير'), '/docs/components/scroll-area', t('Browse content inside a bounded area.', 'تصفّح المحتوى داخل مساحة محدودة.'))} {link(t('Tabs', 'علامات التبويب'), '/docs/components/tabs', t('Switch between related panels.', 'تنقّل بين اللوحات ذات الصلة.'))} {link(t('Tooltip', 'تلميح'), '/docs/components/tooltip', t('Explain a control on focus or hover.', 'اشرح الزر عند التركيز أو التمرير.'))} )} {group(t('With Icon', 'مع أيقونة'), {[ { title: t('Backlog', 'المهام المتراكمة'), icon: , href: '?status=backlog' }, { title: t('To Do', 'قيد الانتظار'), icon: , href: '?status=todo' }, { title: t('Done', 'مكتمل'), icon: , href: '?status=done' }, ].map(item =>
  • }> {item.icon}{item.title}
  • )}
    )} } className={navigationMenuTriggerStyle()} active={destination === '/docs'}>{t('Docs', 'الوثائق')}
    } export default function Example() { return () } ``` ## Primitive libraries ### Base UI The root mounts a positioned popup. Set align on the root, render a router link through render and use closeOnClick for same-page navigation. ```sh npm install wss3-forge @base-ui/react ``` ```tsx import { NavigationMenu, NavigationMenuList, NavigationMenuItem, NavigationMenuTrigger, NavigationMenuContent, NavigationMenuLink } from 'wss3-forge/base-ui' export default function SiteMenu() { return Getting started Installation } ``` #### Preview ```tsx import { useState, type MouseEvent, type ReactNode } from 'react' import { Link as RouterLink } from 'react-router-dom' import { Circle16Regular, CheckmarkCircle16Regular, Info16Regular } from '@fluentui/react-icons' import { VStack, HStack, Text, useMediaQuery } from 'wss3-forge' import { DirectionProvider, NavigationMenu, NavigationMenuList, NavigationMenuItem, NavigationMenuTrigger, NavigationMenuContent, NavigationMenuLink, navigationMenuTriggerStyle } from 'wss3-forge/base-ui' function NavigationExample({ rtl = false }: { rtl?: boolean }) { const [destination, setDestination] = useState('') function selectDestination(event: MouseEvent) { event.preventDefault() setDestination(event.currentTarget.search || event.currentTarget.pathname) } const desktop = useMediaQuery('(min-width: 768px)') const wide = useMediaQuery('(min-width: 1024px)') const t = (english: string, arabic: string) => rtl ? arabic : english const link = (title: string, href: string, description: string) =>
  • }>{title}{description}
  • const group = (name: string, contents: ReactNode) => {name} {contents} const listStyle = { listStyle: 'none', margin: 0, padding: 0, maxWidth: 'calc(100vw - 2rem)' } return {group(t('Getting started', 'البدء'), {link(t('Introduction', 'مقدمة'), '/docs', t('Get to know Forge components and design tokens.', 'تعرّف على مكونات Forge ورموز التصميم.'))} {link(t('Installation', 'التثبيت'), '/docs/installation', t('Install the package and configure your provider.', 'ثبّت الحزمة واضبط المزوّد.'))} {link(t('Typography', 'الطباعة'), '/docs/components/typography', t('Text styles for your headings and paragraphs.', 'أنماط النص للعناوين والفقرات.'))} )} {desktop && group(t('Components', 'المكونات'), {link(t('Alert Dialog', 'مربع التنبيه'), '/docs/components/alert-dialog', t('Request a decision before continuing.', 'اطلب قراراً قبل المتابعة.'))} {link(t('Hover Card', 'بطاقة التمرير'), '/docs/components/hover-card', t('Preview the content behind a link.', 'اعرض معاينة لمحتوى الرابط.'))} {link(t('Progress', 'التقدم'), '/docs/components/progress', t('Show progress toward completion.', 'اعرض التقدم نحو الاكتمال.'))} {link(t('Scroll Area', 'منطقة التمرير'), '/docs/components/scroll-area', t('Browse content inside a bounded area.', 'تصفّح المحتوى داخل مساحة محدودة.'))} {link(t('Tabs', 'علامات التبويب'), '/docs/components/tabs', t('Switch between related panels.', 'تنقّل بين اللوحات ذات الصلة.'))} {link(t('Tooltip', 'تلميح'), '/docs/components/tooltip', t('Explain a control on focus or hover.', 'اشرح الزر عند التركيز أو التمرير.'))} )} {group(t('With Icon', 'مع أيقونة'), {[ { title: t('Backlog', 'المهام المتراكمة'), icon: , href: '?status=backlog' }, { title: t('To Do', 'قيد الانتظار'), icon: , href: '?status=todo' }, { title: t('Done', 'مكتمل'), icon: , href: '?status=done' }, ].map(item =>
  • }> {item.icon}{item.title}
  • )}
    )} } className={navigationMenuTriggerStyle()} active={destination === '/docs'}>{t('Docs', 'الوثائق')}
    } export default function Example() { return () } ``` ### Radix A shared viewport is enabled by default. Set viewport={false} for panels anchored to individual triggers. Use asChild for router links. ```sh npm install wss3-forge radix-ui ``` ```tsx import { NavigationMenu, NavigationMenuList, NavigationMenuItem, NavigationMenuTrigger, NavigationMenuContent, NavigationMenuLink } from 'wss3-forge/radix' export default function SiteMenu() { return Getting started Installation } ``` #### Preview ```tsx import { useState, type MouseEvent, type ReactNode } from 'react' import { Link as RouterLink } from 'react-router-dom' import { VStack, Text, useMediaQuery } from 'wss3-forge' import { DirectionProvider, NavigationMenu, NavigationMenuList, NavigationMenuItem, NavigationMenuTrigger, NavigationMenuContent, NavigationMenuLink, navigationMenuTriggerStyle } from 'wss3-forge/radix' export function NavigationExample({ rtl = false }: { rtl?: boolean }) { const [destination, setDestination] = useState('') function selectDestination(event: MouseEvent) { event.preventDefault() setDestination(event.currentTarget.search || event.currentTarget.pathname) } const desktop = useMediaQuery('(min-width: 768px)') const wide = useMediaQuery('(min-width: 1024px)') const t = (english: string, arabic: string) => rtl ? arabic : english const link = (title: string, href: string, description: string) =>
  • {title}{description}
  • const group = (name: string, contents: ReactNode) => {name} {contents} const listStyle = { listStyle: 'none', margin: 0, padding: 0, maxWidth: 'calc(100vw - 2rem)' } return {group(t('Getting started', 'البدء'), {link(t('Introduction', 'مقدمة'), '/docs', t('Get to know Forge components and design tokens.', 'تعرّف على مكونات Forge ورموز التصميم.'))} {link(t('Installation', 'التثبيت'), '/docs/installation', t('Install the package and configure your provider.', 'ثبّت الحزمة واضبط المزوّد.'))} {link(t('Typography', 'الطباعة'), '/docs/components/typography', t('Text styles for your headings and paragraphs.', 'أنماط النص للعناوين والفقرات.'))} )} {desktop && group(t('Components', 'المكونات'), {link(t('Alert Dialog', 'مربع التنبيه'), '/docs/components/alert-dialog', t('Request a decision before continuing.', 'اطلب قراراً قبل المتابعة.'))} {link(t('Hover Card', 'بطاقة التمرير'), '/docs/components/hover-card', t('Preview the content behind a link.', 'اعرض معاينة لمحتوى الرابط.'))} {link(t('Progress', 'التقدم'), '/docs/components/progress', t('Show progress toward completion.', 'اعرض التقدم نحو الاكتمال.'))} {link(t('Scroll Area', 'منطقة التمرير'), '/docs/components/scroll-area', t('Browse content inside a bounded area.', 'تصفّح المحتوى داخل مساحة محدودة.'))} {link(t('Tabs', 'علامات التبويب'), '/docs/components/tabs', t('Switch between related panels.', 'تنقّل بين اللوحات ذات الصلة.'))} {link(t('Tooltip', 'تلميح'), '/docs/components/tooltip', t('Explain a control on focus or hover.', 'اشرح الزر عند التركيز أو التمرير.'))} )} {t('Docs', 'الوثائق')} } export default function Example() { return () } ``` #### RTL ```tsx import { useState, type MouseEvent, type ReactNode } from 'react' import { Link as RouterLink } from 'react-router-dom' import { VStack, Text, useMediaQuery } from 'wss3-forge' import { DirectionProvider, NavigationMenu, NavigationMenuList, NavigationMenuItem, NavigationMenuTrigger, NavigationMenuContent, NavigationMenuLink, navigationMenuTriggerStyle } from 'wss3-forge/radix' export function NavigationExample({ rtl = false }: { rtl?: boolean }) { const [destination, setDestination] = useState('') function selectDestination(event: MouseEvent) { event.preventDefault() setDestination(event.currentTarget.search || event.currentTarget.pathname) } const desktop = useMediaQuery('(min-width: 768px)') const wide = useMediaQuery('(min-width: 1024px)') const t = (english: string, arabic: string) => rtl ? arabic : english const link = (title: string, href: string, description: string) =>
  • {title}{description}
  • const group = (name: string, contents: ReactNode) => {name} {contents} const listStyle = { listStyle: 'none', margin: 0, padding: 0, maxWidth: 'calc(100vw - 2rem)' } return {group(t('Getting started', 'البدء'), {link(t('Introduction', 'مقدمة'), '/docs', t('Get to know Forge components and design tokens.', 'تعرّف على مكونات Forge ورموز التصميم.'))} {link(t('Installation', 'التثبيت'), '/docs/installation', t('Install the package and configure your provider.', 'ثبّت الحزمة واضبط المزوّد.'))} {link(t('Typography', 'الطباعة'), '/docs/components/typography', t('Text styles for your headings and paragraphs.', 'أنماط النص للعناوين والفقرات.'))} )} {desktop && group(t('Components', 'المكونات'), {link(t('Alert Dialog', 'مربع التنبيه'), '/docs/components/alert-dialog', t('Request a decision before continuing.', 'اطلب قراراً قبل المتابعة.'))} {link(t('Hover Card', 'بطاقة التمرير'), '/docs/components/hover-card', t('Preview the content behind a link.', 'اعرض معاينة لمحتوى الرابط.'))} {link(t('Progress', 'التقدم'), '/docs/components/progress', t('Show progress toward completion.', 'اعرض التقدم نحو الاكتمال.'))} {link(t('Scroll Area', 'منطقة التمرير'), '/docs/components/scroll-area', t('Browse content inside a bounded area.', 'تصفّح المحتوى داخل مساحة محدودة.'))} {link(t('Tabs', 'علامات التبويب'), '/docs/components/tabs', t('Switch between related panels.', 'تنقّل بين اللوحات ذات الصلة.'))} {link(t('Tooltip', 'تلميح'), '/docs/components/tooltip', t('Explain a control on focus or hover.', 'اشرح الزر عند التركيز أو التمرير.'))} )} {t('Docs', 'الوثائق')} } export default function Example() { return () } ``` ## Root package API ### NavigationMenu Navigate between pages with links and groups of related destinations. Props type: `NavigationMenuProps` - `items` — `readonly (NavigationMenuLink | NavigationMenuGroup)[]` Data-driven entry. Provide a destination with href or a group with links. - `label?` — `string` Default `'Site navigation'`. Accessible name of the data-driven navigation landmark. - `renderLink?` — `(item: NavigationMenuLink, close: () => void) => ReactNode` Supply framework-specific routing and call close when the link is activated. ## Related types ```ts export interface NavigationMenuLink { id: string label: string href: string description?: string current?: boolean } export interface NavigationMenuGroup { id: string label: string links: readonly NavigationMenuLink[] } export interface NavigationMenuProps { items: readonly (NavigationMenuLink | NavigationMenuGroup)[] label?: string /** Supply framework-specific routing and call close when the link is activated. */ renderLink?: (item: NavigationMenuLink, close: () => void) => ReactNode } ``` ## Optional primitive contracts - [wss3-forge/base-ui · NavigationMenu contract](/ai/skill/primitive-api/NavigationMenu.json) - [wss3-forge/radix · NavigationMenu contract](/ai/skill/primitive-api/NavigationMenu.json) - [wss3-forge/react-aria · NavigationMenu contract](/ai/skill/primitive-api/NavigationMenu.json)