Skip to content
Haze UI

Navbar with mega menu

Responsive site header with grouped flyouts, optional featured links, and a primary action.

pnpm dlx shadcn@latest add @haze/navbar-mega-menu
Open preview in a new tab
Liveno JavaScript

When to use

  • A site has multiple related destinations under each top-level label
  • Product or resource menus need short descriptions and a featured link

When not to use

  • There are only a few top-level links. Use navbar-simple.
  • Visitors primarily arrive looking for a specific item. Use navbar-search.

Installation

Add the Haze registry to components.json once, then install Navbar with mega menu with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.

pnpm dlx shadcn@latest add @haze/navbar-mega-menu
First time? Registry and theme setup

1. Add to components.json:

{
  "registries": {
    "@haze": "http://localhost:4329/r/{name}.json"
  }
}

2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";

API reference

PropTypeDefaultDescription
idstring"haze-mega-navbar"Supply a unique value per header. Used for the flyout IDs and the CSS anchor.
brandstring"Fieldwork"Text in the wordmark.
homeHrefstring"/"Destination of the wordmark link.
navLabelstring"Main navigation"Accessible name of the navigation landmark.
items(Link | Panel)[]Explore, Learn, BrowseEach link has a label and href. Each panel has a label, groups of titled link lists, and an optional featured link.
actionLink | nullGet startedHeader button destination and label. Pass null to omit.
classstring–Additional classes on the header.

Keyboard interactions

EnterSpace
Open or close the focused flyout.
TabShiftTab
Move through controls and the open flyout links.
Escape
Dismiss the open flyout.

Accessibility

  • The native popover keeps the flyout links out of the tab order while closed.
  • Flyouts are page navigation and preserve regular link behavior and tab order.
  • At narrow widths or without CSS anchors, flyouts open as scrollable centered panels.

Notes for AI

Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.

  • Install and use

    Install the Haze UI block "Navbar with mega menu" with `npx shadcn@latest add @haze/navbar-mega-menu`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import NavbarMegaMenu from "@/components/haze/blocks/navbar-mega-menu.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/blocks/navbar-mega-menu.md

  • Customize with real content

    Adapt the Haze navbar-mega-menu block for our product. Replace the demo values of these props with our real content: id, brand, homeHref, navLabel, items, action, class. Keep the layout, the heading level rules and these accessibility details: The native popover keeps the flyout links out of the tab order while closed. Flyouts are page navigation and preserve regular link behavior and tab order. At narrow widths or without CSS anchors, flyouts open as scrollable centered panels. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using navbar-mega-menu, check it fits: use it when a site has multiple related destinations under each top-level label; product or resource menus need short descriptions and a featured link. Avoid it when there are only a few top-level links. use navbar-simple.; visitors primarily arrive looking for a specific item. use navbar-search.. Alternatives: @haze/navbar-simple, @haze/navbar-centered, @haze/navbar-search, @haze/navigation-menu.

Dependencies

  • npm: @lucide/astro
  • @haze/button
  • @haze/logo-mark
  • @haze/utils
  • @haze/theme (one-time setup)

Source · Original Haze UI work.

Catalog

↑↓ moveEnter openEsc close

Keyboard shortcuts

CtrlK
Command palette
/
Focus search
←↑→↓
Move between cards
jk
Next / previous card
ci
Copy code / install command (detail page)
[]
Previous / next entry
?
This help
Esc
Close dialog