--- title: Navigation Menu description: A collection of links for navigating websites. component: true links: doc: https://www.radix-ui.com/docs/primitives/components/navigation-menu api: https://www.radix-ui.com/docs/primitives/components/navigation-menu#api-reference source: radix: true shadcn: true --- ## Installation CLI Manual ```bash npx shadcn-ui@latest add navigation-menu ``` Install the following dependencies: ```bash npm install @radix-ui/react-navigation-menu ``` Copy and paste the following code into your project. Update the import paths to match your project setup. ## Usage ```tsx import { NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, } from '@/components/ui/navigation-menu' ``` ```tsx Item One Link ``` ## Examples ### Link Component When using the Next.js `` component, you can use `navigationMenuTriggerStyle()` to apply the correct styles to the trigger. ```tsx import { navigationMenuTriggerStyle } from '@/components/ui/navigation-menu' ``` ```tsx {3-5} Documentation ``` See also the [Radix UI documentation](https://www.radix-ui.com/docs/primitives/components/navigation-menu#with-client-side-routing) for handling client side routing. ### With horizontal scroll We can wrap a the `` in a `` component to make the menu scroll. However, then we must also make sure the `` is positioned correctly and rendered outside the scroll area. We set `renderViewport={false}` on the `` component to prevent the viewport from being rendered. And then add our own Viewport with ``. Then all our content panels will render themselves outside the scroll area and inside the viewport. You can also add props to `` to style it as you like, including the `containerProps` prop to add classes to the container div element inside the viewport. ```tsx {1, 2, 11-13} Item One Link ```