CraftUI

Navigation Menu

Site navigation as a top bar or an Ore UI settings-style sidebar.

Installation

npx shadcn@latest add @runqora/craft-navigation-menu

Usage

import {
  NavigationMenu,
  NavigationMenuContent,
  NavigationMenuItem,
  NavigationMenuLink,
  NavigationMenuList,
  NavigationMenuTrigger,
} from "@/components/craft/navigation-menu";

<NavigationMenu aria-label="Main">
  <NavigationMenuList>
    <NavigationMenuItem>
      <NavigationMenuLink active href="/play">
        Play
      </NavigationMenuLink>
    </NavigationMenuItem>
    <NavigationMenuItem>
      <NavigationMenuTrigger>Marketplace</NavigationMenuTrigger>
      <NavigationMenuContent>
        <NavigationMenuLink href="/marketplace/worlds">Worlds</NavigationMenuLink>
      </NavigationMenuContent>
    </NavigationMenuItem>
  </NavigationMenuList>
</NavigationMenu>;

Examples

Set orientation="vertical" for a sidebar, as in Ore UI's settings. NavigationMenuLabel heads each section, and panels open to the side.

Props

Prop

Type

Prop

Type

Accessibility

  • It's a nav landmark. When a page has more than one, name each with aria-label.
  • The current page's link has aria-current="page", as well as its underline or lifted row.
  • Tab moves between the items. Enter, Space or the arrow keys open a panel, and Escape closes it.
  • Panels open on hover too, after a short delay, and stay open while the pointer moves into them.

Customization

For client-side routing, pass your framework's link through render:

import NextLink from "next/link";

<NavigationMenuLink active render={<NextLink href="/settings" />}>
  Settings
</NavigationMenuLink>;

Dependencies

Source

On this page