Navigation Menu
Site navigation bar with hover/click panels in a shared resizing viewport, built on Radix NavigationMenu.
Preview
Changelog · Nov 3
Routes now remember the tide
Malik's crew can now plan a loop around low water: stops shift on their own when the tide turns.
Install
Add the editable source with the shadcn CLI. Your project also needs the shared theme tokens this component uses. Setup and requirements. The Pebble installer is not published yet.
npx shadcn@latest add https://pebbleui.com/r/navigation-menu.jsonProps
| Prop | Type | Default | Description |
|---|---|---|---|
| viewport | boolean | true | Render panels in one shared, resizing viewport; false floats each panel under its trigger. |
| value | string | - | Controlled open item (empty string = none). |
| defaultValue | string | - | Initially open item (uncontrolled). |
| onValueChange | (value: string) => void | - | Called when the open item changes. |
| delayDuration | number | 200 | Hover delay in ms before a panel opens. |
| orientation | "horizontal" | "vertical" | "horizontal" | Direction of the top-level list for arrow-key navigation. |
| NavigationMenuLink.active | boolean | false | Marks the current page (aria-current="page", data-active). |
| navigationMenuTriggerStyle() | () => string | - | Trigger class string, for direct links in the top-level list. |
Build notes
Radix NavigationMenu supplies open state, hover delays, keyboard model, the
`data-motion` direction attribute on content, and the measured
`--radix-navigation-menu-viewport-width/height` variables. The viewport sits in
an absolutely positioned wrapper at `top-full` of the root and sizes itself
from those variables; a `transition-[width,height]` makes it
morph between panels (durations and curves: see the Pebble note). It opens with `nav-menu-in` (opacity 0 / scale 0.96 to
1, origin top) and closes with `nav-menu-out`;
the closing animation keeps Radix Presence mounted until it ends.
Content panels slide with four keyframes keyed on `data-motion`:
`nav-menu-from-end` / `nav-menu-from-start` (translateX ±13rem→0 with fade,
entering) and `nav-menu-to-end` / `nav-menu-to-start` (the reverse,
leaving). With `viewport={false}` the root carries `data-viewport=false`, and
group variants (`group-data-[viewport=false]/navigation-menu:`) turn each
panel into a standalone card surface below the bar using the
same `nav-menu-in/out` keyframes. The indicator fades with
`nav-menu-fade-in/out`. All keyframes ship in the registry item's `css` field.
No `cva`: `navigationMenuTriggerStyle()` is a plain function returning a `cn`
string. Floating surfaces use `card` tokens (this library has no popover
token).
**Pebble (2026-11-03).** Triggers and `navigationMenuTriggerStyle()` are compact and quiet: `h-9`, `px-3`, transparent with muted text, going to ink on a `bg-muted` fill on hover, focus and open, and `data-[active]` direct links read as ink; colours ease over `--motion-fast` and the old 3 px ring is replaced by the shared focus recipe. The viewport (and each standalone panel with `viewport={false}`) is a raised Pebble surface: `bg-card`, `rounded-xl`, `ring-1 ring-hairline`, `shadow-raised-md`, `inset-shadow-highlight`, 8 px below the bar, no border; the indicator arrow is a card square with a hairline ring. Panel links get `p-2.5`, the focus recipe and icons that brighten to ink with the highlight. Every keyframe keeps its name and body but runs on tokens: viewport and panel `nav-menu-in` over `--motion-base` + `--motion-enter`, `nav-menu-out` over `--motion-fast` + `--motion-exit`, the four `data-motion` slides over `--motion-base` (enter curve in, exit curve out), the indicator fades likewise; the width/height morph is `--motion-base` on the move curve, and the chevron rotates over `--motion-base` on the move curve, all still behind `motion-safe:`. The demo is a site header in a raised bar (an original route mark, a current Changelog link, a signed-in teammate) with two panels of different sizes: a 2-column product grid with SVG icons and a guides panel led by an original contour-map illustration with author and read-time rows.
<!-- PEBBLE-LICENSE -->View source
registry/nav/navigation-menu/navigation-menu.tsx
"use client";
/* PEBBLE-LICENSE
Built by Pebble. Component: navigation-menu.
First-party license: MIT
The following first-party terms apply only to original Pebble material.
MIT License
Copyright (c) 2026 Praxys Solutions LLC (Pebble)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
THIRD-PARTY NOTICES
These notices apply to identified upstream portions; Pebble terms do not replace or narrow their rights.
Upstream: https://raw.githubusercontent.com/shadcn-ui/ui/main/LICENSE.md
MIT License
Copyright (c) 2023 shadcn
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
END PEBBLE-LICENSE */
import * as React from "react";
import { NavigationMenu as NavigationMenuPrimitive } from "radix-ui";
import { cn } from "@/lib/utils";
export function NavigationMenu({
className,
children,
viewport = true,
...props
}: React.ComponentProps<typeof NavigationMenuPrimitive.Root> & {
/** Render panels inside one shared, resizing viewport (default) or under each trigger. */
viewport?: boolean;
}) {
return (
<NavigationMenuPrimitive.Root
data-slot="navigation-menu"
data-viewport={viewport}
className={cn(
"group/navigation-menu relative flex max-w-full min-w-0 flex-1 items-center justify-center md:max-w-max",
className,
)}
{...props}
>
{children}
{viewport ? <NavigationMenuViewport /> : null}
</NavigationMenuPrimitive.Root>
);
}
export function NavigationMenuList({
className,
...props
}: React.ComponentProps<typeof NavigationMenuPrimitive.List>) {
return (
<NavigationMenuPrimitive.List
data-slot="navigation-menu-list"
// Wraps rather than overflowing on narrow screens.
className={cn("flex flex-1 list-none flex-wrap items-center justify-center gap-1", className)}
{...props}
/>
);
}
export function NavigationMenuItem({
className,
...props
}: React.ComponentProps<typeof NavigationMenuPrimitive.Item>) {
return (
<NavigationMenuPrimitive.Item
data-slot="navigation-menu-item"
className={cn("relative", className)}
{...props}
/>
);
}
/**
* Class string for a top-level menu button. Apply it to a plain
* `NavigationMenuLink` so direct links line up with the triggers.
*/
export function navigationMenuTriggerStyle() {
return cn(
// Quiet at rest (muted text on the bar), ink on hover, focus, open or current.
"inline-flex h-9 w-max flex-row items-center justify-center gap-1 rounded-md bg-transparent px-3 py-0 text-sm font-medium text-muted-foreground outline-none",
"transition-colors duration-(--motion-fast) ease-enter motion-reduce:transition-none",
"hover:bg-muted hover:text-foreground focus:bg-muted focus:text-foreground",
"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background focus-visible:outline-hidden",
"disabled:pointer-events-none disabled:opacity-50",
"data-[state=open]:bg-muted data-[state=open]:text-foreground",
"data-[active]:text-foreground",
"forced-colors:border forced-colors:border-[ButtonText]",
);
}
export function NavigationMenuTrigger({
className,
children,
...props
}: React.ComponentProps<typeof NavigationMenuPrimitive.Trigger>) {
return (
<NavigationMenuPrimitive.Trigger
data-slot="navigation-menu-trigger"
className={cn(navigationMenuTriggerStyle(), "group", className)}
{...props}
>
{children}
<svg
viewBox="0 0 16 16"
fill="none"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
aria-hidden="true"
data-slot="navigation-menu-trigger-icon"
className="relative top-px size-3 shrink-0 opacity-70 group-hover:opacity-100 group-data-[state=open]:rotate-180 group-data-[state=open]:opacity-100 motion-safe:transition-transform motion-safe:duration-(--motion-base) motion-safe:ease-move"
>
<path d="m4 6 4 4 4-4" />
</svg>
</NavigationMenuPrimitive.Trigger>
);
}
export function NavigationMenuContent({
className,
...props
}: React.ComponentProps<typeof NavigationMenuPrimitive.Content>) {
return (
<NavigationMenuPrimitive.Content
data-slot="navigation-menu-content"
className={cn(
"top-0 left-0 w-full p-1.5 md:absolute md:w-auto",
// Inside the shared viewport: slide in from the side the pointer came from.
"motion-safe:data-[motion=from-end]:animate-[nav-menu-from-end_var(--motion-base)_var(--motion-enter)]",
"motion-safe:data-[motion=from-start]:animate-[nav-menu-from-start_var(--motion-base)_var(--motion-enter)]",
"motion-safe:data-[motion=to-end]:animate-[nav-menu-to-end_var(--motion-base)_var(--motion-exit)]",
"motion-safe:data-[motion=to-start]:animate-[nav-menu-to-start_var(--motion-base)_var(--motion-exit)]",
// Without the viewport: each panel is its own raised card under its trigger.
"group-data-[viewport=false]/navigation-menu:top-full group-data-[viewport=false]/navigation-menu:mt-2 group-data-[viewport=false]/navigation-menu:overflow-hidden group-data-[viewport=false]/navigation-menu:rounded-xl group-data-[viewport=false]/navigation-menu:bg-card group-data-[viewport=false]/navigation-menu:text-card-foreground group-data-[viewport=false]/navigation-menu:shadow-raised-md group-data-[viewport=false]/navigation-menu:ring-1 group-data-[viewport=false]/navigation-menu:inset-shadow-highlight group-data-[viewport=false]/navigation-menu:ring-hairline group-data-[viewport=false]/navigation-menu:forced-colors:border group-data-[viewport=false]/navigation-menu:forced-colors:border-[CanvasText]",
"motion-safe:group-data-[viewport=false]/navigation-menu:data-[state=closed]:animate-[nav-menu-out_var(--motion-fast)_var(--motion-exit)] motion-safe:group-data-[viewport=false]/navigation-menu:data-[state=open]:animate-[nav-menu-in_var(--motion-base)_var(--motion-enter)]",
className,
)}
{...props}
/>
);
}
export function NavigationMenuViewport({
className,
...props
}: React.ComponentProps<typeof NavigationMenuPrimitive.Viewport>) {
return (
<div
data-slot="navigation-menu-viewport-wrapper"
className="absolute top-full left-0 isolate z-50 flex justify-center"
>
<NavigationMenuPrimitive.Viewport
data-slot="navigation-menu-viewport"
className={cn(
// A raised Pebble surface: hairline ring, 1 px top light, md elevation.
"relative mt-2 h-(--radix-navigation-menu-viewport-height) w-full origin-top overflow-hidden rounded-xl bg-card text-card-foreground shadow-raised-md ring-1 inset-shadow-highlight ring-hairline md:w-(--radix-navigation-menu-viewport-width)",
"forced-colors:border forced-colors:border-[CanvasText]",
// Resize smoothly between panels of different sizes.
"motion-safe:transition-[width,height] motion-safe:duration-(--motion-base) motion-safe:ease-move",
"motion-safe:data-[state=closed]:animate-[nav-menu-out_var(--motion-fast)_var(--motion-exit)] motion-safe:data-[state=open]:animate-[nav-menu-in_var(--motion-base)_var(--motion-enter)]",
className,
)}
{...props}
/>
</div>
);
}
export function NavigationMenuLink({
className,
...props
}: React.ComponentProps<typeof NavigationMenuPrimitive.Link>) {
return (
<NavigationMenuPrimitive.Link
data-slot="navigation-menu-link"
className={cn(
"flex flex-col gap-1 rounded-md p-2.5 text-sm outline-none",
"transition-colors duration-(--motion-fast) ease-enter motion-reduce:transition-none",
"hover:bg-muted hover:text-foreground focus:bg-muted focus:text-foreground",
"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background focus-visible:outline-hidden",
"data-[active]:bg-muted data-[active]:text-foreground",
"hover:[&_svg:not([class*='text-'])]:text-foreground focus:[&_svg:not([class*='text-'])]:text-foreground",
"[&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",
className,
)}
{...props}
/>
);
}
export function NavigationMenuIndicator({
className,
...props
}: React.ComponentProps<typeof NavigationMenuPrimitive.Indicator>) {
return (
<NavigationMenuPrimitive.Indicator
data-slot="navigation-menu-indicator"
className={cn(
"top-full z-[1] flex h-2 items-end justify-center overflow-hidden",
"motion-safe:data-[state=hidden]:animate-[nav-menu-fade-out_var(--motion-fast)_var(--motion-exit)] motion-safe:data-[state=visible]:animate-[nav-menu-fade-in_var(--motion-base)_var(--motion-enter)]",
className,
)}
{...props}
>
<div
data-slot="navigation-menu-indicator-arrow"
className="relative top-[60%] size-2 rotate-45 rounded-tl-sm bg-card ring-1 ring-hairline"
/>
</NavigationMenuPrimitive.Indicator>
);
}
