Navigation Menu
Navigation Menu with thoughtful defaults, semantic styling, and editable source.
Make it yours.
Install the editable source and its dependencies into your React + Tailwind project.
Scroll horizontally for long lines
pnpm dlx shadcn@4.0.8 add http://localhost:3000/r/navigation-menu.jsonUse it
Scroll horizontally for long lines
"use client";
import {NavigationMenu} from '@/components/jez-ui/ui/navigation-menu';
export default function Example(){
return <><NavigationMenu items={[{label:'Components',href:'/components'},{label:'Blocks',href:'/blocks'},{label:'Templates',href:'/templates'}]}/></>;
}Props & types
Scroll horizontally for long lines
{
items: { label: string; href: string }[];
className?: string;
}Source
View 2 source files
registry/ui/navigation-menu.tsx
Scroll horizontally for long lines
"use client";
import * as React from "react";
import { cn } from "./utils";
import { NavigationMenu as Primitive } from "radix-ui";
export function NavigationMenu({
items,
className,
}: {
items: { label: string; href: string }[];
className?: string;
}) {
return (
<Primitive.Root className={cn("", className)}>
<Primitive.List className="flex flex-wrap gap-1">
{items.map((i) => (
<Primitive.Item key={i.href}>
<Primitive.Link
href={i.href}
className="block rounded-lg px-3 py-2 text-sm hover:bg-muted"
>
{i.label}
</Primitive.Link>
</Primitive.Item>
))}
</Primitive.List>
</Primitive.Root>
);
}
registry/ui/utils.ts
Scroll horizontally for long lines
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...values: ClassValue[]) {
return twMerge(clsx(values));
}
Dependencies
radix-ui@1.6.7 · clsx@2.1.1 · tailwind-merge@3.5.0
Accessibility & behaviour
Provide meaningful labels and preserve keyboard focus styles. Check contrast when customising theme colours.
Read the accessibility and performance guide →