Skip to content
Haze UI

Navbar: centered brand with mobile menu

A centered desktop brand with navigation on one side and a native mobile disclosure.

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

When to use

  • A short primary navigation should flank a centered brand
  • The mobile navigation should remain usable without JavaScript

When not to use

  • A large navigation needs the popover menu used by navbar-simple
  • Many desktop links would wrap beyond one row

Installation

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

pnpm dlx shadcn@latest add @haze/navbar-centered
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
brandstring"Driftwork"Brand name in the logo and home link.
homeHrefstring"/"Home destination for the brand.
links{ label: string; href: string }[]3 example anchorsShort list of navigation links; replace example anchors with real destinations.
actionLabelstring"Get started"Text for the optional action link.
actionHrefstring"#start"Action destination; pass an empty string to hide it.
classstring–Additional header classes.

Keyboard interactions

Tab, Enter or Space
Focus and toggle the mobile navigation, then visit its links.

Accessibility

  • The mobile menu uses native details and summary, which expose its expanded state without a script.
  • The icon changes with the disclosure state; the summary retains a stable accessible name.

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: centered brand with mobile menu" with `npx shadcn@latest add @haze/navbar-centered`. 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 NavbarCentered from "@/components/haze/blocks/navbar-centered.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-centered.md

  • Customize with real content

    Adapt the Haze navbar-centered block for our product. Replace the demo values of these props with our real content: brand, homeHref, links, actionLabel, actionHref, class. Keep the layout, the heading level rules and these accessibility details: The mobile menu uses native details and summary, which expose its expanded state without a script. The icon changes with the disclosure state; the summary retains a stable accessible name. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using navbar-centered, check it fits: use it when a short primary navigation should flank a centered brand; the mobile navigation should remain usable without javascript. Avoid it when a large navigation needs the popover menu used by navbar-simple; many desktop links would wrap beyond one row. Alternatives: @haze/navbar-simple.

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