Skip to content
Haze UI

Morphic navbar

Inverted morphic pill bar where inactive links fuse seamlessly and the active destination splits apart with rounded neighbor corners.

pnpm dlx shadcn@latest add @haze/morphic-navbar
Open preview in a new tab
Livesmall script

When to use

  • A top-level section bar needs a tactile split-pill silhouette across three to six destinations
  • A compact floating header needs automatic collapse into a native popover menu on narrow viewports
  • In-page or SPA navigation benefits from crisp corner-morphing continuity when switching routes

When not to use

  • Navigation needs multi-column mega menus or nested link groups; use navigation-menu
  • Controls toggle local view state rather than page destinations; use segmented-control or tabs

Installation

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

pnpm dlx shadcn@latest add @haze/morphic-navbar
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
id*string–Unique caller-supplied ID used to connect the mobile menu trigger and popover.
items{ label: string; href: string; current?: boolean }[]5 sample linksOrdered navigation destinations; mark the active item with current.
labelstring"Primary navigation"Accessible label for the navigation landmark and mobile popover header.
menuLabelstring"Open navigation menu"Accessible name for the narrow-viewport menu trigger button.
closeLabelstring"Close menu"Accessible name for the close button inside the mobile popover.
classstring–Additional classes on the outer nav container.

Keyboard interactions

TabShiftTab
Move focus into the bar or onto the mobile menu button
ArrowLeftArrowRight
Move focus between desktop links inside the pill bar
Enter
Activate the focused navigation link or toggle the mobile menu
Escape
Close the mobile navigation popover

Accessibility

  • Marks the active destination with aria-current="page" and computes initial split corners server-side so the morphing geometry renders without JavaScript.
  • Uses native popover and popovertarget for the narrow-viewport menu so Escape, light-dismiss and focus restoration work automatically.
  • Disables corner and margin transitions when prefers-reduced-motion is active.

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 component "Morphic navbar" with `npx shadcn@latest add @haze/morphic-navbar`. 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 MorphicNavbar from "@/components/haze/ui/morphic-navbar.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/ui/morphic-navbar.md

  • Customize with real content

    Adapt the Haze morphic-navbar ui for our product. Replace the demo values of these props with our real content: id, items, label, menuLabel, closeLabel, class. Keep the layout, the heading level rules and these accessibility details: Marks the active destination with aria-current="page" and computes initial split corners server-side so the morphing geometry renders without JavaScript. Uses native popover and popovertarget for the narrow-viewport menu so Escape, light-dismiss and focus restoration work automatically. Disables corner and margin transitions when prefers-reduced-motion is active. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using morphic-navbar, check it fits: use it when a top-level section bar needs a tactile split-pill silhouette across three to six destinations; a compact floating header needs automatic collapse into a native popover menu on narrow viewports; in-page or spa navigation benefits from crisp corner-morphing continuity when switching routes. Avoid it when navigation needs multi-column mega menus or nested link groups; use navigation-menu; controls toggle local view state rather than page destinations; use segmented-control or tabs. Alternatives: @haze/navigation-menu, @haze/segmented-control, @haze/tabs.

Dependencies

  • npm: @lucide/astro
  • @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