本文へ移動
日本語
「ナビゲーションメニュー」は Pro に含まれます。解除するとプレビューが表示されます。

仕組み

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.

向いている場面

  • Marketing and documentation sites with a few rich sections.
  • Headers where each section benefits from descriptions and icons.

向かない場面

  • Application commands: use a menubar or dropdown menu.
  • Small screens: collapse into a drawer instead.

使い方

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' },
      ]}
    />
  )
}

プロパティ

プロパティ型既定値説明
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).
labelstring—Accessible name of the nav landmark.
defaultOpenstring | nullnullItem open on first render.
openDelaynumber120Hover delay in ms before the first panel opens.
closeDelaynumber240Grace period in ms after the pointer leaves.
...restHTMLAttributes<HTMLElement>—Other attributes go to the <nav>; set --ds-nm-duration in style to change the morph time.

アクセシビリティ

  • 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.

モーション

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.

プロジェクトに追加

Pro メンバーはプロンプトをコピーし、コーディングエージェントが無料コンポーネントと同じ手順でソースを導入します。

NavigationMenu.jsxnavigation-menu.csstokens.cssREADME.md

2 つのファイルを一緒に導入します。スタイルは tokens.css の変数を読み、予備の値も持つため、単体でも表示できます。

ナビゲーション