# Navbar: simple with mobile menu

> Sticky translucent top bar with wordmark, links, optional sign-in and a CTA from lg. Below lg a floating panel menu fades and slides in.

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

## Use when
- A marketing site with up to six top-level pages
- You want a mobile menu that works with zero JavaScript

## Avoid when
- You need mega-menu dropdowns with grouped links per item

## Props

| Name | Type | Default | Required | Description |
|---|---|---|---|---|
| brand | `string` | "Driftwork" | no | Wordmark text, also used for the home link label. |
| logoShape | `"circle" \| "square" \| "triangle" \| "diamond" \| "haze"` | "diamond" | no | Glyph shape passed to LogoMark. |
| links | `{ label: string; href: string }[]` | 5 demo links | no | Top-level navigation links. |
| signInHref | `string` | "#sign-in" | no | Target of the ghost Sign in button. An empty string hides the button. |
| signInLabel | `string` | "Sign in" | no | Label of the Sign in button. |
| ctaLabel | `string` | "Start free" | no | Primary button label. |
| ctaHref | `string` | "#start" | no | Primary button target. |
| menuId | `string` | "haze-navbar-menu" | no | Id of the mobile popover; must be unique on the page. |

## Accessibility
- Wrapped in <header> with <nav aria-label="Main">.
- The mobile menu uses the native popover API: the toggle button exposes its expanded state and Esc closes the menu without script.
- Key Enter / Space: Open or close the mobile menu from the menu button
- Key Esc: Close the mobile menu

## Agent prompts

### Install and use

Install the Haze UI block "Navbar: simple with mobile menu" with `npx shadcn@latest add @haze/navbar-simple`. 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 NavbarSimple from "@/components/haze/blocks/navbar-simple.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-simple.md

### Customize with real content

Adapt the Haze navbar-simple block for our product. Replace the demo values of these props with our real content: brand, logoShape, links, signInHref, signInLabel, ctaLabel, ctaHref, menuId. Keep the layout, the heading level rules and these accessibility details: Wrapped in <header> with <nav aria-label="Main">. The mobile menu uses the native popover API: the toggle button exposes its expanded state and Esc closes the menu without script. Do not add raw color classes; use the Haze tokens.

### Choose the right block

Before using navbar-simple, check it fits: use it when a marketing site with up to six top-level pages; you want a mobile menu that works with zero javascript. Avoid it when you need mega-menu dropdowns with grouped links per item.

## Example requests that should lead here
- Add a top navbar with five links, a sign in link and a Start free button
- I need a header whose menu collapses into a hamburger on phones without adding 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;
  logoShape?: "circle" | "square" | "triangle" | "diamond" | "haze";
  links?: { label: string; href: string; current?: boolean }[];
  /** Target of the Sign in button. Pass an empty string to hide the button. */
  signInHref?: string;
  /** Label of the Sign in button. */
  signInLabel?: string;
  ctaLabel?: string;
  ctaHref?: string;
  /** Unique id for the mobile menu popover; change it if a page has two navbars. */
  menuId?: string;
}

const {
  brand = "Driftwork",
  logoShape = "diamond",
  links = [
    { label: "Product", href: "#product" },
    { label: "Customers", href: "#customers" },
    { label: "Pricing", href: "#pricing" },
    { label: "Changelog", href: "#changelog" },
    { label: "Docs", href: "#docs" },
  ],
  signInHref = "#sign-in",
  signInLabel = "Sign in",
  ctaLabel = "Start free",
  ctaHref = "#start",
  menuId = "haze-navbar-menu",
} = Astro.props;
---

<header class="sticky top-0 z-40 border-b border-border bg-background/80 px-6 backdrop-blur">
  <nav aria-label="Main" class="mx-auto flex h-14 max-w-6xl items-center justify-between gap-6 sm:h-16">
    <a href="/" aria-label={`${brand} home`} class="inline-flex min-h-8 items-center rounded-md focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ring">
      <LogoMark name={brand} shape={logoShape} class="text-foreground" />
    </a>
    <ul class="hidden items-center gap-1 lg:flex">
      {
        links.map((link) => (
          <li>
            <a
              href={link.href}
              aria-current={link.current ? "page" : undefined}
              class="rounded-md px-3 py-2 text-sm font-medium text-muted-foreground transition-colors duration-150 hover:bg-foreground/8 hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring aria-[current=page]:bg-foreground/8 aria-[current=page]:text-foreground"
            >
              {link.label}
            </a>
          </li>
        ))
      }
    </ul>
    <div class="hidden items-center gap-2 lg:flex">
      <slot name="actions" />
      {signInHref && <Button href={signInHref} variant="ghost" size="sm">{signInLabel}</Button>}
      <Button href={ctaHref} size="sm">{ctaLabel}</Button>
    </div>
    <button
      type="button"
      popovertarget={menuId}
      aria-label="Open menu"
      class="inline-flex size-9 cursor-pointer items-center justify-center rounded-lg text-foreground transition-[background-color,scale] duration-150 ease-snappy hover:bg-foreground/8 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring active:scale-90 active:duration-75 lg:hidden"
    >
      <Menu class="size-5" aria-hidden="true" />
    </button>
    <div
      id={menuId}
      popover
      class={cn(
        "inset-x-0 top-0 bottom-auto m-0 h-auto max-h-dvh w-full max-w-none overflow-y-auto rounded-none border-0 border-b border-border-strong bg-popover p-4 text-popover-foreground shadow-float backdrop:bg-background/60",
        "-translate-y-2 opacity-0 transition-[opacity,translate,overlay,display] transition-discrete duration-150 ease-snappy open:translate-y-0 open:opacity-100 starting:open:-translate-y-2 starting:open:opacity-0",
      )}
    >
      <div class="flex h-10 items-center justify-between">
        <LogoMark name={brand} shape={logoShape} class="text-foreground" />
        <button
          type="button"
          popovertarget={menuId}
          popovertargetaction="hide"
          aria-label="Close menu"
          class="inline-flex size-9 cursor-pointer items-center justify-center rounded-lg text-foreground transition-[background-color,scale] duration-150 ease-snappy hover:bg-foreground/8 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring active:scale-90 active:duration-75"
        >
          <X class="size-5" aria-hidden="true" />
        </button>
      </div>
      <ul class="mt-4 flex flex-col gap-0.5">
        {
          links.map((link) => (
            <li>
              <a
                href={link.href}
                aria-current={link.current ? "page" : undefined}
                class="flex min-h-10 w-full items-center rounded-md px-3 text-sm font-medium text-foreground transition-colors duration-150 hover:bg-foreground/8 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring aria-[current=page]:bg-foreground/8 aria-[current=page]:text-foreground"
              >
                {link.label}
              </a>
            </li>
          ))
        }
      </ul>
      <div class="mt-4 grid gap-2 border-t border-border pt-4">
        <slot name="mobile-actions" />
        {signInHref && <Button href={signInHref} variant="outline">{signInLabel}</Button>}
        <Button href={ctaHref}>{ctaLabel}</Button>
      </div>
    </div>
  </nav>
</header>
```
