Specification
- Catalogue
- No. 1 of 110
- Section
- Navigation
- Interaction
- Hover, Layout Animation
- Element
- Navigation
- Preview
- Live component
- Imports
- react 19.3.1
- Added
Notes
One pill glides between the menu items, and one dropdown follows it.
The eye follows a single moving thing instead of items blinking on and off. The dropdown stays open while you move across, its arrow slides to the new item and the new panel enters from the side you moved toward.
Pill glides 250ms, cubic-bezier(.22, 1, .36, 1). Opens 200ms ease-out, closes 150ms ease-in. New panel slides 100px from the side moved toward, 250ms.
Code
React and plain CSS"use client";
import { NavMenu } from "@/components/pieces/kit/nav-menu";
import type { LivePreviewProps } from "@/components/live/types";
import { PieceStage } from "@/components/pieces/stage/PieceStage";
import type { Tour } from "@/components/pieces/stage/tour";
import "./nav-menu.css";
const links = (items: string[]) =>
items.map((l) => (
<a key={l} href="#" className="dm-link">
{l}
</a>
));
const rows = (items: [string, string][]) => (
<div className="dm-rows">
{items.map(([title, line]) => (
<a key={title} href="#" className="dm-row">
<strong>{title}</strong>
<span>{line}</span>
</a>
))}
</div>
);
function NavMenuDemo() {
return (
<div className="dm dm-nav">
<div className="dm-nav-bar">
<span className="dm-wordmark">Your brand</span>
<NavMenu
items={[
{
label: "Product",
panel: (
<div className="dm-panel-grid">
<div className="dm-col">
<p className="dm-col-title">Use it</p>
{links(["In the browser", "On your phone", "With your team"])}
</div>
<div className="dm-col">
<p className="dm-col-title">Learn</p>
{links(["How it works", "Guides", "Help"])}
</div>
</div>
),
},
{
label: "Pricing",
panel: rows([
["Starter", "For one person getting going"],
["Team", "Shared projects and roles"],
["Business", "Single sign-on and support"],
]),
},
{
label: "Company",
panel: rows([
["About", "Who we are and how we work"],
["Careers", "Open roles"],
["Contact", "Talk to a person"],
]),
},
]}
/>
<a href="#" className="dm-cta">
Sign in
</a>
</div>
<p className="dm-hint">Point at the menu, then move across it</p>
</div>
);
}
// What a hovered card shows: the piece used the way a visitor would.
const TOUR: Tour = [
{ click: ".nav-menu-trigger", nth: 0, wait: 1300 },
{ click: ".nav-menu-trigger", nth: 1, wait: 1300 },
{ click: ".nav-menu-trigger", nth: 2, wait: 1300 },
{ click: ".nav-menu-trigger", nth: 2, wait: 500 },
];
export default function NavMenuEntry(props: LivePreviewProps) {
return (
<PieceStage {...props} label="Gliding menu" tour={TOUR}>
<NavMenuDemo />
</PieceStage>
);
}