Web · Components
NavigationMenu
Site header menu (mega menu): links and dropdown panels.
7 exports
Live example
Preview
Company
On this page
Code
TSX
import { NavigationMenu } from "@yasinsensoy/web";
<NavigationMenu
items={[
{ label: "Products", items: [
{ label: "Analytics", href: "/products/analytics", icon: "chart", description: "Real-time reports" },
{ label: "Automation", href: "/products/automation", badge: "New" },
], featured: campaignCard },
{ label: "Solutions", items: [{ title: "By industry", items: [...] }, { title: "By team", items: [...] }] },
{ label: "Pricing", href: "/pricing" },
]}
/>Events
- Events appear here when you interact with the preview.
Import
TSX
import { NavigationMenu } from "@yasinsensoy/web";Site header menu (mega menu): links and dropdown panels. For a corporate site, product page or docs site header.
- Panels: a link list (icon, description, badge), titled columns, a featured card or your own content entirely. When switching between panels the background slides to the new panel's size and position.
- Opening: on mouse hover (delayed, doesn't close while moving to the panel), on press for touch and keyboard. Closes on an outside click, with Esc and when focus leaves the menu.
- Keyboard: ← / → between top items, ↓ opens the panel and goes to the first link, ↑ / ↓ navigate in the panel, Esc closes and returns to the button. The Tab order is natural.
- SEO: links in panels are rendered on the server (kept hidden); search engines see them.
- Active page: the path comes from
UIProviderusePathname; the related top item and link are marked witharia-current. - Mobile: below
breakpointa menu button and a side sheet; panels become collapsible groups, and the back button closes it.
For in-app (dashboard) navigation see Sidebar.
TypeScript
NavigationMenu({ items, currentPath, openOn, openDelay, closeDelay, align, breakpoint, mobileSide, mobileTitle, mobileFooter, label, className, classNames, effect, }: NavigationMenuProps): JSX.ElementExamples
TSX
<NavigationMenu
items={[
{ label: "Products", items: [
{ label: "Analytics", href: "/products/analytics", icon: "chart", description: "Real-time reports" },
{ label: "Automation", href: "/products/automation", badge: "New" },
], featured: <CampaignCard /> },
{ label: "Pricing", href: "/pricing" },
]}
/>NavigationMenuLink
interfaceA link in the NavigationMenu dropdown panel.
| Name | Type | Default | Description |
|---|---|---|---|
label | ReactNode | Link text. | |
href? | string | URL. In-site URLs open with the UIProvider link component (Next.js Link), external URLs in a new tab. | |
description? | ReactNode | Short description under the title. | |
icon? | IconProp | Leading icon. | |
badge? | ReactNode | Small badge on the right ("New", "Beta"). | |
active? | boolean | Is it the active page? If omitted, the URL is compared with the current path. | |
exact? | boolean | false | Count as active only when the URL matches exactly. |
disabled? | boolean | Cannot be selected. | |
onSelect? | (event: MouseEvent<HTMLElement>) => void | On click (before navigating). Without href it becomes a button. |
NavigationMenuSection
interfaceA titled column of links in the NavigationMenu panel.
| Name | Type | Description |
|---|---|---|
title | ReactNode | Column title. |
items | readonly NavigationMenuLink[] | Links in the column. |
NavigationMenuItem
interfaceAn item in the NavigationMenu top bar: a link or a dropdown panel.
| Name | Type | Default | Description |
|---|---|---|---|
items? | readonly (NavigationMenuLink | NavigationMenuSection)[] | Links or titled columns in the dropdown panel. If given, the item becomes a button that opens the panel (href is the "See all" link on mobile). | |
columns? | 1 | 2 | 3 | 4 | 1 or 2 by link count | How many columns the links are laid out in (without sections). |
featured? | ReactNode | A featured card at the start of the panel (campaign, product promo). | |
content? | ReactNode | Your own panel content entirely, instead of links. | |
footer? | ReactNode | The strip at the bottom of the panel ("All products →"). | |
width? | string | Panel width on desktop (e.g. "36rem"). If omitted, by content. | |
label | ReactNode | Link text. | |
href? | string | URL. In-site URLs open with the UIProvider link component (Next.js Link), external URLs in a new tab. | |
icon? | IconProp | Leading icon. | |
badge? | ReactNode | Small badge on the right ("New", "Beta"). | |
active? | boolean | Is it the active page? If omitted, the URL is compared with the current path. | |
exact? | boolean | false | Count as active only when the URL matches exactly. |
disabled? | boolean | Cannot be selected. | |
onSelect? | (event: MouseEvent<HTMLElement>) => void | On click (before navigating). Without href it becomes a button. |
Width at which NavigationMenu switches to the mobile view.
TypeScript
type NavigationMenuBreakpoint = "sm" | "md" | "lg" | "never"NavigationMenuClassNames
interfaceClasses that can be passed to the inner parts of NavigationMenu.
| Name | Type | Description |
|---|---|---|
trigger? | string | An item in the top bar (link or button). |
panel? | string | Dropdown panel. |
link? | string | A link in the panel. |
mobileTrigger? | string | Mobile menu button. |
NavigationMenuProps
interfaceProps of the NavigationMenu component.
| Name | Type | Default | Description |
|---|---|---|---|
items | readonly NavigationMenuItem[] | Items in the top bar. See NavigationMenuItem. | |
currentPath? | string | null | Path of the current page. If omitted, UIProvider usePathname. | |
openOn? | "hover" | "click" | "hover" | How panels open: "hover" on mouse hover (on press for touch and keyboard); "click" only on press. |
openDelay? | number | 120 | Open delay on hover (ms). |
closeDelay? | number | 250 | Close delay after the mouse leaves (ms); so it doesn't close while moving to the panel. |
align? | "start" | "center" | "start" | Alignment of the panel relative to the trigger. |
breakpoint? | NavigationMenuBreakpoint | "md" | Below this width a menu button and side sheet appear instead of the bar. The switch is done with CSS; there is no jump in server rendering. |
mobileSide? | "left" | "right" | "left" | Edge the mobile sheet opens from. |
mobileTitle? | ReactNode | "Menü" | Title of the mobile sheet. |
mobileFooter? | ReactNode | Footer of the mobile sheet (e.g. a "Sign in" button). | |
label? | string | "Ana menü"` (`messages.navigation`) | Screen reader name. |
className? | string | Classes added to the container. | |
classNames? | NavigationMenuClassNames | Classes added to the inner parts. | |
effect? | EffectProp | Effect or effects of the top-level links and buttons (e.g. "ripple", ["lift", "glow"]). If omitted, UIProvider appearance.defaults.navigationMenu.effect. See BuiltinEffect. |