Components

Navigation Menu

The shadcn/ui Navigation Menu with a viewport that morphs its size between panels, direction-aware panel slides and a gliding indicator — plus an animated React mega menu block built with Motion and Radix for site headers, with a hover highlight that glides between items.

  • Drop-in shadcn API
  • Morphing viewport
  • Direction-aware
  • Radix hover intent
  • Motion block

Installation

$ npx shadcn@latest add https://duskui.com/r/navigation-menu.json

Same exports and props as the shadcn/ui Navigation Menu, including navigationMenuTriggerStyle and viewport={false}. Animations are CSS (tw-animate-css), so the base needs no Motion.

Usage

site-nav.tsx
import {
  NavigationMenu,
  NavigationMenuContent,
  NavigationMenuItem,
  NavigationMenuLink,
  NavigationMenuList,
  NavigationMenuTrigger,
  navigationMenuTriggerStyle,
} from "@/components/ui/navigation-menu"

export function SiteNav() {
  return (
    <NavigationMenu>
      <NavigationMenuList>
        <NavigationMenuItem>
          <NavigationMenuTrigger>Products</NavigationMenuTrigger>
          <NavigationMenuContent>
            <ul className="grid w-[400px] gap-1 p-1">
              <li>
                <NavigationMenuLink href="/analytics">Analytics</NavigationMenuLink>
              </li>
            </ul>
          </NavigationMenuContent>
        </NavigationMenuItem>
        <NavigationMenuItem>
          <NavigationMenuLink href="/docs" className={navigationMenuTriggerStyle()}>
            Docs
          </NavigationMenuLink>
        </NavigationMenuItem>
      </NavigationMenuList>
    </NavigationMenu>
  )
}

Examples

Default

Hover or focus a trigger. Panels share one viewport that eases its width and height to fit each panel, the incoming panel shifts in from the side you're moving toward while the old one leaves the other way (Radix's data-motion), and the indicator arrow glides under the open trigger.

Without a viewport

With viewport={false} each panel drops down under its own trigger as a small popover that scales in from the top. Set active on a link to mark the current page.

Blocks

Ready-made variations composed from the base component with Motion. Each installs on its own and pulls in its dependencies automatically.

Mega Menu

A data-driven header menu. A highlight glides between bar items as you hover (a shared Motion layoutId), the viewport fades open and then morphs its width and height between panels, panels slide in the direction of travel, links stagger in and an arrow tracks the open item. Panels can have a featured card and any number of link columns; items without a panel are plain links. Pass linkAs={Link} to use Next.js links.

$ npx shadcn@latest add https://duskui.com/r/mega-menu.json
PropTypeDefaultDescription
itemsMegaMenuItem[]—Bar items: { label, href?, featured?, columns? }.
featured{ eyebrow?, title, description?, href }—Highlighted card on the left of a panel.
columns{ heading?, links: { title, href, description?, icon?, badge? }[] }[]—Link columns in a panel.
linkAsElementType"a"Link component, e.g. Next.js Link. Must forward ref and props.
value / defaultValue / onValueChangestring / string / (value: string) => void—The open item's label (empty when closed).
delayDurationnumber120Hover delay before a panel opens, in ms.

API Reference

Same parts as shadcn/ui: NavigationMenu, List, Item, Trigger, Content, Link, Viewport and Indicator (all prefixed NavigationMenu), plus navigationMenuTriggerStyle(). Each forwards the Radix props.

PropTypeDefaultDescription
viewportbooleantrueRender panels in a shared, morphing viewport (on NavigationMenu).
value / defaultValue / onValueChangestring / string / (value: string) => void—Controlled open item (on NavigationMenu).
delayDuration / skipDelayDurationnumber / number200 / 300Hover intent timing in ms (on NavigationMenu).
orientation"horizontal" | "vertical""horizontal"Layout and arrow-key direction (on NavigationMenu).
activeboolean—Marks the current page with aria-current (on NavigationMenuLink).
onSelect(event: Event) => void—Fires when a link is chosen; the menu closes (on NavigationMenuLink).

Accessibility

  • Built on Radix Navigation Menu: triggers are buttons with aria-expanded and aria-controls, panels are linked back with aria-labelledby, and the active link gets aria-current="page".
  • Tab moves through triggers and into the open panel; arrow keys move between triggers; Enter, Space or ArrowDown opens a panel and Escape closes it, returning focus to its trigger.
  • Hover intent delays avoid panels flickering open as the pointer passes over the bar.
  • The mega menu's highlight follows keyboard focus as well as the pointer.
  • Under prefers-reduced-motion panels fade instead of sliding and the viewport changes size instantly.