Skip to content

feat(topnav): unified card appearance for mega menu - #356

Merged
rubyycheung merged 1 commit into
mainfrom
navi/feat/mega-menu-unified-card
Feb 26, 2026
Merged

rubyycheung merged 1 commit into
mainfrom
navi/feat/mega-menu-unified-card

Conversation

@rubyycheung

Copy link
Copy Markdown
Contributor

Summary

When a mega menu opens, the nav bar and dropdown panel now appear as one continuous popover card — no divider, shared shadow, seamless surface.

Changes

  • Backdrop element — an absolutely-positioned div covers the entire nav wrapper, providing the unified card shadow and rounded corners
  • No divider — removed the border-top between the nav bar and panel so they flow as one surface
  • onOpenChange callback — fires when the menu opens/closes so the wrapper can coordinate (e.g. hide its own shadow)
  • Updated sandbox demo — wrapper shadow fades out when a menu opens, letting the backdrop's card shadow take over

How it works

The XDSTopNavMegaMenu renders a backdrop <div> that positions itself over the entire position: relative wrapper. When the menu opens, the backdrop fades in with the card shadow, and the panel slides down seamlessly from the nav bar.

const [menuOpen, setMenuOpen] = useState(false);

<div style={{ position: 'relative', boxShadow: menuOpen ? 'none' : '...' }}>
  <XDSTopNav
    startContent={
      <XDSTopNavMegaMenu
        label="Products"
        items={items}
        onOpenChange={setMenuOpen}
      />
    }
  />
</div>

Test Plan

  • npx tsc --noEmit — clean
  • All 36 existing TopNav tests pass
  • Sandbox demo at /pages/mega-menu/ updated with unified card behavior

Crafted with care by Navi

When a mega menu opens, the nav bar and dropdown panel now appear as
one continuous popover card with shared shadow and rounded corners.
No divider between the nav bar and the panel content.

- Added backdrop element that covers the positioned ancestor
- Removed panel border-top and separate shadow
- Added onOpenChange callback for wrapper coordination
- Updated sandbox demo to hide wrapper shadow when menu is open

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 added this pull request to the merge queue Feb 26, 2026
@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 922 -
Complexity N/A Very High (49) -

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

Merged via the queue into main with commit 3726b3a Feb 26, 2026
9 of 10 checks passed
cixzhang pushed a commit that referenced this pull request Apr 26, 2026
When a mega menu opens, the nav bar and dropdown panel now appear as
one continuous popover card with shared shadow and rounded corners.
No divider between the nav bar and the panel content.

- Added backdrop element that covers the positioned ancestor
- Removed panel border-top and separate shadow
- Added onOpenChange callback for wrapper coordination
- Updated sandbox demo to hide wrapper shadow when menu is open

Co-authored-by: Navi <[email protected]>
cixzhang pushed a commit that referenced this pull request Jun 21, 2026
When a mega menu opens, the nav bar and dropdown panel now appear as
one continuous popover card with shared shadow and rounded corners.
No divider between the nav bar and the panel content.

- Added backdrop element that covers the positioned ancestor
- Removed panel border-top and separate shadow
- Added onOpenChange callback for wrapper coordination
- Updated sandbox demo to hide wrapper shadow when menu is open

Co-authored-by: Navi <[email protected]>
cixzhang pushed a commit that referenced this pull request Jun 21, 2026
When a mega menu opens, the nav bar and dropdown panel now appear as
one continuous popover card with shared shadow and rounded corners.
No divider between the nav bar and the panel content.

- Added backdrop element that covers the positioned ancestor
- Removed panel border-top and separate shadow
- Added onOpenChange callback for wrapper coordination
- Updated sandbox demo to hide wrapper shadow when menu is open
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.

1 participant