Skip to content

feat(topnav): add XDSTopNavMegaMenu component - #354

Merged
rubyycheung merged 2 commits into
mainfrom
navi/feat/mega-menu-topnav
Feb 26, 2026
Merged

rubyycheung merged 2 commits into
mainfrom
navi/feat/mega-menu-topnav

Conversation

@rubyycheung

Copy link
Copy Markdown
Contributor

Summary

Adds a full-width mega menu variant for the top navigation bar. On hover over a nav item, a panel drops down with menu items organized in a two-column grid and an optional featured content area on the right.

New Component: XDSTopNavMegaMenu

Features

  • Hover trigger — nav item with chevron indicator that opens a full-width panel below the nav bar
  • Two-column item grid — menu items with icon, title, and description
  • Featured content area — optional right-side panel with image, title, description, and CTA link
  • Smooth animation — fade + slide-up transition on open/close
  • Configurable timing — delay and hideDelay props for hover behavior
  • Single column mode — singleColumn prop for fewer items
  • Keyboard support — Escape to dismiss
  • Accessible — aria-haspopup, aria-expanded, role="menu", role="menuitem"

Usage

Wrap XDSTopNav in a container with position: relative so the mega menu panel spans the full nav width:

<div style={{ position: 'relative' }}>
  <XDSTopNav
    startContent={
      <XDSTopNavMegaMenu
        label="Products"
        items={[
          { title: 'Analytics', description: 'Track behavior', icon: <ChartIcon /> },
          { title: 'Messaging', description: 'Real-time comms', icon: <ChatIcon /> },
        ]}
        featured={{
          image: '/promo.jpg',
          title: "What's new in v4.0",
          description: 'Explore the latest features.',
          linkText: 'Learn more →',
          linkHref: '/blog/v4',
        }}
      />
    }
  />
</div>

Props

Prop Type Default Description
label string — Trigger button label (required)
items XDSTopNavMegaMenuItemData[] — Menu items (required)
featured XDSTopNavMegaMenuFeatured — Optional featured content area
delay number 150 Show delay on hover (ms)
hideDelay number 250 Hide delay after mouse leaves (ms)
singleColumn boolean false Use single column layout

Test Plan

  • npx tsc --noEmit — clean
  • All 36 existing TopNav tests pass
  • Sandbox demo page at /pages/mega-menu/ with two examples:
    1. Marketing nav with featured content (Products + Solutions menus)
    2. Simple nav without featured content (Features menu, single column)

Files Changed

File Change
packages/core/src/TopNav/XDSTopNavMegaMenu.tsx New component
packages/core/src/TopNav/index.ts Added exports
apps/sandbox/src/app/pages/mega-menu/page.tsx New demo page
apps/sandbox/src/app/Sidebar.tsx Added sidebar link

Crafted with care by Navi

Adds a full-width mega menu variant for the top navigation bar.
On hover, a nav item reveals a panel with menu items organized in
a two-column grid and an optional featured content area on the right.

- New XDSTopNavMegaMenu component with hover trigger + chevron
- Two-column item grid with icon, title, and description
- Optional featured section with image, title, description, and CTA
- Configurable hover delay, hide delay, and single-column mode
- Smooth fade + slide animation on open/close
- Keyboard support (Escape to dismiss)
- Proper ARIA attributes (aria-haspopup, aria-expanded, role=menu)
- Sandbox demo page at /pages/mega-menu/

Co-authored-by: Navi <[email protected]>
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Feb 26, 2026
@rubyycheung
rubyycheung marked this pull request as draft February 26, 2026 04:59
@github-actions

github-actions Bot commented Feb 26, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

Modified Components

TopNav · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 383B N/A
Lines of Code N/A 888 -
Complexity N/A Very High (47) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@xds/core 8.0KB 12.9KB 2.0KB

Accessibility Audit

Status: No accessibility violations detected.

Component Previews

Includes interactive hover previews as animated GIFs.

XDSTopNav

Default

Screenshot:

Default

Interaction Preview: (view video)

Default interaction

View in Storybook · navigation-xdstopnav--default

With Logo

Screenshot:

With Logo

View in Storybook · navigation-xdstopnav--with-logo

Title Only

Screenshot:

Title Only

View in Storybook · navigation-xdstopnav--title-only

Nav Item States

Screenshot:

Nav Item States

View in Storybook · navigation-xdstopnav--nav-item-states

Centered Navigation

Screenshot:

Centered Navigation

View in Storybook · navigation-xdstopnav--centered-navigation

Centered With Start Content

Screenshot:

Centered With Start Content

View in Storybook · navigation-xdstopnav--centered-with-start-content

Center Content Without End

Screenshot:

Center Content Without End

View in Storybook · navigation-xdstopnav--center-content-without-end

Full Example

Screenshot:

Full Example

View in Storybook · navigation-xdstopnav--full-example


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

…aming convention

The @xds/boolean-prop-naming lint rule requires boolean props to use
'is' or 'has' prefix. Renamed singleColumn → isSingleColumn in
XDSTopNavMegaMenu and updated the sandbox page reference.

Co-authored-by: Navi <[email protected]>
@rubyycheung
rubyycheung marked this pull request as ready for review February 26, 2026 05:07
@rubyycheung
rubyycheung added this pull request to the merge queue Feb 26, 2026
Merged via the queue into main with commit 3aa7e06 Feb 26, 2026
9 of 10 checks passed
@thedjpetersen
thedjpetersen deleted the navi/feat/mega-menu-topnav branch March 1, 2026 11:02
cixzhang pushed a commit that referenced this pull request Apr 26, 2026
* feat(topnav): add XDSTopNavMegaMenu component

Adds a full-width mega menu variant for the top navigation bar.
On hover, a nav item reveals a panel with menu items organized in
a two-column grid and an optional featured content area on the right.

- New XDSTopNavMegaMenu component with hover trigger + chevron
- Two-column item grid with icon, title, and description
- Optional featured section with image, title, description, and CTA
- Configurable hover delay, hide delay, and single-column mode
- Smooth fade + slide animation on open/close
- Keyboard support (Escape to dismiss)
- Proper ARIA attributes (aria-haspopup, aria-expanded, role=menu)
- Sandbox demo page at /pages/mega-menu/

Co-authored-by: Navi <[email protected]>

* fix(topnav): rename singleColumn to isSingleColumn per boolean prop naming convention

The @xds/boolean-prop-naming lint rule requires boolean props to use
'is' or 'has' prefix. Renamed singleColumn → isSingleColumn in
XDSTopNavMegaMenu and updated the sandbox page reference.

Co-authored-by: Navi <[email protected]>

---------

Co-authored-by: Navi <[email protected]>
Co-authored-by: thedjpetersen <[email protected]>
cixzhang pushed a commit that referenced this pull request Jun 21, 2026
* feat(topnav): add XDSTopNavMegaMenu component

Adds a full-width mega menu variant for the top navigation bar.
On hover, a nav item reveals a panel with menu items organized in
a two-column grid and an optional featured content area on the right.

- New XDSTopNavMegaMenu component with hover trigger + chevron
- Two-column item grid with icon, title, and description
- Optional featured section with image, title, description, and CTA
- Configurable hover delay, hide delay, and single-column mode
- Smooth fade + slide animation on open/close
- Keyboard support (Escape to dismiss)
- Proper ARIA attributes (aria-haspopup, aria-expanded, role=menu)
- Sandbox demo page at /pages/mega-menu/

Co-authored-by: Navi <[email protected]>

* fix(topnav): rename singleColumn to isSingleColumn per boolean prop naming convention

The @xds/boolean-prop-naming lint rule requires boolean props to use
'is' or 'has' prefix. Renamed singleColumn → isSingleColumn in
XDSTopNavMegaMenu and updated the sandbox page reference.

Co-authored-by: Navi <[email protected]>

---------

Co-authored-by: Navi <[email protected]>
Co-authored-by: thedjpetersen <[email protected]>
cixzhang pushed a commit that referenced this pull request Jun 21, 2026
* feat(topnav): add XDSTopNavMegaMenu component

Adds a full-width mega menu variant for the top navigation bar.
On hover, a nav item reveals a panel with menu items organized in
a two-column grid and an optional featured content area on the right.

- New XDSTopNavMegaMenu component with hover trigger + chevron
- Two-column item grid with icon, title, and description
- Optional featured section with image, title, description, and CTA
- Configurable hover delay, hide delay, and single-column mode
- Smooth fade + slide animation on open/close
- Keyboard support (Escape to dismiss)
- Proper ARIA attributes (aria-haspopup, aria-expanded, role=menu)
- Sandbox demo page at /pages/mega-menu/


* fix(topnav): rename singleColumn to isSingleColumn per boolean prop naming convention

The @xds/boolean-prop-naming lint rule requires boolean props to use
'is' or 'has' prefix. Renamed singleColumn → isSingleColumn in
XDSTopNavMegaMenu and updated the sandbox page reference.


---------

Co-authored-by: thedjpetersen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants