Cómo funciona
Every panel is laid out at its own width and measured; one background surface animates width, height and translateX to the active box, clamped inside the bar, while the content cross-fades with a 28px directional slide. A bridge element covers the gap below the bar so the pointer can travel into the panel, and a short close delay forgives diagonal moves.
Úsalo para
- Marketing and documentation sites with a few rich sections.
- Headers where each section benefits from descriptions and icons.
Busca otra opción cuando
- Application commands: use a menubar or dropdown menu.
- Small screens: collapse into a drawer instead.
Uso
import { NavigationMenu } from './NavigationMenu.jsx'
export function Header() {
return (
<NavigationMenu
label="Main"
items={[
{
id: 'product',
label: 'Product',
width: 560,
featured: { title: 'Canvas', description: 'One shared board.', href: '/canvas' },
links: [
{ title: 'Boards', description: 'Plan work in flexible views', href: '/boards', icon: <BoardIcon /> },
{ title: 'Docs', description: 'Write together', href: '/docs', badge: 'New' },
],
},
{ id: 'resources', label: 'Resources', width: 300, links: [{ title: 'Guides', href: '/guides' }] },
{ id: 'pricing', label: 'Pricing', href: '/pricing' },
]}
/>
)
}Propiedades
| Propiedad | Tipo | Por defecto | Qué hace |
|---|---|---|---|
items | { id, label, href?, width?, featured?: { title, description, href }, links?: { title, description?, href, icon?, badge? }[], content?: ReactNode }[] | — | Top items. An item with href is a plain link; otherwise it opens a panel built from featured and links, or your own content. width is the panel's preferred width (capped by the bar). |
label | string | — | Accessible name of the nav landmark. |
defaultOpen | string | null | null | Item open on first render. |
openDelay | number | 120 | Hover delay in ms before the first panel opens. |
closeDelay | number | 240 | Grace period in ms after the pointer leaves. |
...rest | HTMLAttributes<HTMLElement> | — | Other attributes go to the <nav>; set --ds-nm-duration in style to change the morph time. |
Accesibilidad
- A nav landmark with a list of disclosure buttons (aria-expanded, aria-controls) and plain links; the panel is a region labelled by its trigger.
- Enter, Space or Down opens a panel and focuses its first link; Left and Right move between triggers and switch the open panel.
- Tab from an open trigger enters the panel, Tab past the last link continues to the next trigger, Shift+Tab from the first link returns; Up and Down move between links.
- Escape closes and returns focus to the trigger; a click outside closes.
- Hidden panels are inert and aria-hidden, so only the open one is reachable.
- With reduced motion panels only fade; the background, caret and chevron do not move.
Movimiento
Background width, height and position 320ms cubic-bezier(0.22, 1, 0.36, 1); content slides 28px with the same curve, the old one fades in 180ms; the panel opens in 220ms from 0.97 scale at the caret.
Añádelo a tu proyecto
Los miembros Pro copian un prompt y su agente de programación instala el código, igual que con los gratuitos.
NavigationMenu.jsxnavigation-menu.csstokens.cssREADME.md
Los dos archivos se instalan juntos. La hoja de estilos lee las variables de tokens.css y lleva valores de reserva, así que también funciona sola.

