Navigation Menu
A collection of links for navigating websites.
'use client'
import React from 'react'
import {
NavigationMenu,
NavigationMenuContent,
NavigationMenuItem,
NavigationMenuLink,
NavigationMenuList,
NavigationMenuTrigger,
navigationMenuTriggerStyle
} from '@immit/ui/navigation-menu'
import { cn } from '@immit/ui/utils'
import Link, { type LinkProps } from 'next/link'
const components: { title: string; href: string; description: string }[] = [
{
title: 'Alert Dialog',
href: '/components/alert-dialog',
description:
'A modal dialog that interrupts the user with important content and expects a response.'
},
{
title: 'Hover Card',
href: '/components/hover-card',
description: 'For sighted users to preview content available behind a link.'
},
{
title: 'Progress',
href: '/components/progress',
description:
'Displays an indicator showing the completion progress of a task, typically displayed as a progress bar.'
},
{
title: 'Scroll-area',
href: '/components/scroll-area',
description: 'Visually or semantically separates content.'
},
{
title: 'Tabs',
href: '/components/tabs',
description:
'A set of layered sections of content—known as tab panels—that are displayed one at a time.'
},
{
title: 'Tooltip',
href: '/components/tooltip',
description:
'A popup that displays information related to an element when the element receives keyboard focus or the mouse hovers over it.'
}
]
export function NavigationMenuDemo() {
return (
<NavigationMenu>
<NavigationMenuList>
<NavigationMenuItem>
<NavigationMenuTrigger>Getting started</NavigationMenuTrigger>
<NavigationMenuContent>
<ul className="grid gap-3 p-6 md:w-[400px] lg:w-[500px] lg:grid-cols-[.75fr_1fr]">
<ListItem href="/overview/introduction" title="Introduction">
Re-usable components built using Radix UI and Tailwind CSS.
</ListItem>
<ListItem href="/overview/installation" title="Installation">
How to install dependencies and structure your app.
</ListItem>
</ul>
</NavigationMenuContent>
</NavigationMenuItem>
<NavigationMenuItem>
<NavigationMenuTrigger>Components</NavigationMenuTrigger>
<NavigationMenuContent>
<ul className="grid w-[400px] gap-3 p-4 md:w-[500px] md:grid-cols-2 lg:w-[600px]">
{components.map((component) => (
<ListItem
key={component.title}
title={component.title}
href={component.href}
>
{component.description}
</ListItem>
))}
</ul>
</NavigationMenuContent>
</NavigationMenuItem>
<NavigationMenuItem>
<NavigationMenuLink asChild className={navigationMenuTriggerStyle()}>
<Link href="/overview/introduction">Documentation</Link>
</NavigationMenuLink>
</NavigationMenuItem>
</NavigationMenuList>
</NavigationMenu>
)
}
export function ListItem({
className,
title,
children,
...props
}: Omit<React.ComponentProps<'a'>, 'ref'> & LinkProps) {
return (
<li>
<NavigationMenuLink asChild>
<Link
className={cn(
'hover:bg-accent hover:text-accent focus:bg-accent focus:text-accent block select-none space-y-1 rounded-md p-3 leading-none no-underline outline-none transition-colors',
className
)}
{...props}
>
<div className="text-sm font-medium leading-none">{title}</div>
<p className="text-muted line-clamp-2 text-sm leading-snug">
{children}
</p>
</Link>
</NavigationMenuLink>
</li>
)
}