# Navbar: centered brand with mobile menu

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

- Kind: block · Category: Navbar · Interactivity: native
- Install: `npx shadcn@latest add @haze/navbar-centered`
- File: `src/components/haze/blocks/navbar-centered.astro`
- npm dependencies: @lucide/astro
- Registry dependencies: @haze/button, @haze/logo-mark, @haze/utils
- Docs page: https://hazeui.com/blocks/navbar-centered

## Use when
- A short primary navigation should flank a centered brand
- The mobile navigation should remain usable without JavaScript

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

## Alternatives
- [navbar-simple](https://hazeui.com/blocks/navbar-simple.md)

## Props

| Name | Type | Default | Required | Description |
|---|---|---|---|---|
| brand | `string` | "Driftwork" | no | Brand name in the logo and home link. |
| homeHref | `string` | "/" | no | Home destination for the brand. |
| links | `{ label: string; href: string }[]` | 3 example anchors | no | Short list of navigation links; replace example anchors with real destinations. |
| actionLabel | `string` | "Get started" | no | Text for the optional action link. |
| actionHref | `string` | "#start" | no | Action destination; pass an empty string to hide it. |
| class | `string` |  | no | Additional header classes. |

## 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.
- Key Tab, Enter or Space: Focus and toggle the mobile navigation, then visit its links.

## Agent prompts

### 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": "https://hazeui.com/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: https://hazeui.com/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.

## Example requests that should lead here
- Create a centered-logo navbar with a mobile menu that works without JavaScript

## Source

```astro
---
import { Menu, X } from "@lucide/astro";
import { cn } from "../../../lib/haze/utils";
import Button from "../ui/button.astro";
import LogoMark from "../ui/logo-mark.astro";

interface Props {
  brand?: string;
  homeHref?: string;
  links?: { label: string; href: string }[];
  actionLabel?: string;
  actionHref?: string;
  class?: string;
}

const {
  brand = "Driftwork",
  homeHref = "/",
  links = [{ label: "Product", href: "#product" }, { label: "Customers", href: "#customers" }, { label: "About", href: "#about" }],
  actionLabel = "Get started",
  actionHref = "#start",
  class: className,
} = Astro.props;
---

<header class={cn("border-b border-border bg-muted/40", className)}>
  <nav aria-label="Main" class="relative mx-auto grid h-16 max-w-6xl grid-cols-[1fr_auto] items-center gap-4 px-6 lg:grid-cols-[1fr_auto_1fr]">
    <ul class="hidden flex-wrap items-center gap-1 lg:flex">
      {links.map((link) => <li><a href={link.href} class="inline-flex min-h-10 items-center rounded-md px-3 text-sm/5 font-medium text-muted-foreground transition-colors duration-150 ease-snappy hover:bg-foreground/8 hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring">{link.label}</a></li>)}
    </ul>
    <a href={homeHref} aria-label={`${brand} home`} class="inline-flex w-fit rounded-md focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ring"><LogoMark name={brand} shape="diamond" class="text-foreground" /></a>
    <div class="hidden justify-end lg:flex">{actionHref && <Button href={actionHref} size="sm">{actionLabel}</Button>}</div>
    <details class="group lg:hidden">
      <summary aria-label="Navigation menu" class="flex size-10 cursor-pointer list-none items-center justify-center rounded-lg text-foreground transition-colors duration-150 ease-snappy hover:bg-foreground/8 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring [&::-webkit-details-marker]:hidden">
        <Menu aria-hidden="true" class="size-5 group-open:hidden" /><X aria-hidden="true" class="hidden size-5 group-open:block" />
      </summary>
      <div class="absolute inset-x-0 top-full z-10 max-h-[calc(100dvh-4rem)] overflow-y-auto border-b border-border-strong bg-popover p-4 text-popover-foreground shadow-float">
        <ul class="grid gap-1">
          {links.map((link) => <li><a href={link.href} class="flex min-h-10 items-center rounded-md px-3 text-sm/5 font-medium text-foreground transition-colors duration-150 ease-snappy hover:bg-foreground/8 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring">{link.label}</a></li>)}
        </ul>
        {actionHref && <div class="mt-4 border-t border-border pt-4"><Button href={actionHref} class="w-full">{actionLabel}</Button></div>}
      </div>
    </details>
  </nav>
</header>
```
