Header
Site headers — a navbar (bar or floating pill shape), dropdown nav, a mega-menu and a product-site header with grouped panels.
Preview
@props([
'brand' => 'Acme',
'brandHref' => '#',
'links' => null,
'cta' => 'Sign in',
'ctaHref' => '#',
'shape' => 'bar',
])
@php
$links ??= [
['label' => 'Products', 'href' => '#'],
['label' => 'Pricing', 'href' => '#'],
['label' => 'Docs', 'href' => '#'],
['label' => 'Blog', 'href' => '#'],
];
$pill = $shape === 'pill';
@endphp
<header
x-data="{ open: false }"
{{ $attributes->merge([
'data-slot' => 'header-01',
'class' => $pill
? 'sticky top-0 z-40 w-full bg-background text-foreground'
: 'sticky top-0 z-40 w-full border-b border-border bg-background/90 text-foreground backdrop-blur',
]) }}
>
<nav
@class([
'mx-auto flex items-center justify-between gap-4',
'mt-4 max-w-3xl rounded-full border border-border bg-card/80 px-4 py-2 shadow-lg backdrop-blur ps-6' => $pill,
'max-w-7xl px-4 py-4 sm:px-6 lg:px-8' => ! $pill,
])
aria-label="{{ __('Main') }}"
>
<x-ui.brand :href="$brandHref" :label="$brand" :shape="$pill ? 'pill' : 'square'" />
<ul class="hidden items-center gap-2 md:flex">
@foreach ($links as $link)
<li>
<a
href="{{ $link['href'] }}"
@class([
'px-4 py-2 text-sm font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
'rounded-full' => $pill,
'rounded-md' => ! $pill,
])
>
{{ __($link['label']) }}
</a>
</li>
@endforeach
</ul>
<div class="hidden md:block">
<x-ui.button :href="$ctaHref" size="sm" class="{{ $pill ? 'rounded-full' : '' }}">{{ __($cta) }}</x-ui.button>
</div>
<button
type="button"
@class([
'inline-flex items-center justify-center text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring md:hidden',
'size-9 rounded-full' => $pill,
'size-10 rounded-md' => ! $pill,
])
:aria-expanded="open.toString()"
aria-controls="header-01-mobile"
@click="open = ! open"
>
<span class="sr-only">{{ __('Toggle menu') }}</span>
<svg class="size-5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">
<path x-show="! open" d="M4 6h16M4 12h16M4 18h16" stroke-linecap="round" />
<path x-show="open" x-cloak d="M6 6l12 12M18 6L6 18" stroke-linecap="round" />
</svg>
</button>
</nav>
<div
id="header-01-mobile"
x-show="open"
x-cloak
x-transition.opacity
@click.outside="open = false"
@keydown.escape.window="open = false"
@class([
'md:hidden',
'mx-auto mt-2 max-w-3xl rounded-lg border border-border bg-card/95 p-6 shadow-lg backdrop-blur' => $pill,
'border-t border-border' => ! $pill,
])
>
<ul @class(['space-y-2', 'px-4 py-4' => ! $pill])>
@foreach ($links as $link)
<li>
<a href="{{ $link['href'] }}" class="block rounded-md px-4 py-2 text-sm font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">
{{ __($link['label']) }}
</a>
</li>
@endforeach
<li class="pt-2">
<x-ui.button :href="$ctaHref" size="sm" class="{{ $pill ? 'w-full rounded-full' : 'w-full' }}">{{ __($cta) }}</x-ui.button>
</li>
</ul>
</div>
</header>
Installation
php artisan ui:add blocks/header-navbar
Registry contract
Install confidence
php artisan ui:add blocks/header-navbar
writes only the generated targets below. The CLI validates each file hash before writing and
prompts before replacing local changes unless --force is used.
- Version
- 1.1.2
- License
- open
- Stability
- stable
- Contract
- v1
- Foundation
- ≥ 1.0.0
| Type | Generated target |
|---|---|
| blade | resources/views/blocks/header-navbar.blade.php |
Registry dependencies
Package dependencies
composer: jml/brok:^0.2
Use with AI
A brief for your coding agent: what the block is, the install command, how to render it, its props and the rules. Copy it, or open a prompt about this block in an assistant.
# Brok UI block: Navbar (`header-navbar`)
A responsive top navigation bar with brand, links, a call-to-action, and an Alpine-powered mobile menu, in a full-width bar or a detached floating pill shape.
Brok UI is a Laravel Blade registry. `ui:add` copies this block into the app as plain Blade the app owns; it composes installed `<brok:*>` primitives and semantic design tokens.
## Install
```bash
php artisan ui:add blocks/header-navbar
```
## Render it
```blade
<x-blocks.header-navbar shape="bar" />
```
## Props
- `shape` (bar|pill, default `bar`) (variant) — bar is a full-width border-bottom navbar; pill is a detached, rounded, backdrop-blurred floating bar.
## Use when
- Building a sticky top navigation bar with brand, links, and a call-to-action that collapses into an Alpine-powered mobile menu.
- Choosing between a full-width bordered bar or a detached rounded floating pill shape via the shape prop.
## Avoid when
- Use header-dropdown instead when the navigation needs a dropdown menu for product links.
## Rules
- Render the installed block with `<x-blocks.header-navbar />` and pass data through its props; edit the copied file only for structural changes.
- Keep the semantic design tokens (`bg-background`, `text-muted-foreground`); never swap in raw colour utilities.
- Keep the `data-slot` attributes and the logical (start/end) spacing so the markup still mirrors under `dir="rtl"`.
## Links
- Docs: https://brokui.dev/blocks/header-navbar
- Registry JSON (files, props, contract): https://brokui.dev/r/open/blocks/header-navbar.json
Working in Claude Code, Cursor or Codex? Give the agent the whole registry through the MCP server or the Brok UI skill.
Guidance
Use when
- Building a sticky top navigation bar with brand, links, and a call-to-action that collapses into an Alpine-powered mobile menu.
- Choosing between a full-width bordered bar or a detached rounded floating pill shape via the shape prop.
Avoid when
- Use header-dropdown instead when the navigation needs a dropdown menu for product links.
Anti-patterns
- Do not replace semantic props with conflicting utility classes.
- Do not remove labels, focus styles, or state attributes.
- Anatomy
Usage
Render the block as a component, passing data where useful:
<x-blocks.header-navbar />
The controls above the preview are props on this composition. What you picked reads:
Built from primitives
This block composes installed <brok:*> primitives and semantic design
tokens only — it does not reimplement any primitive. Re-theme it (light, dark, admin, customer) by
editing CSS variables; flip the preview to RTL to confirm it mirrors.
Source
The exact, editable file ui:add writes
into your app. The preview above renders this same source — there are no preview-only blocks.
@props([
'brand' => 'Acme',
'brandHref' => '#',
'links' => null,
'cta' => 'Sign in',
'ctaHref' => '#',
'shape' => 'bar',
])
@php
$links ??= [
['label' => 'Products', 'href' => '#'],
['label' => 'Pricing', 'href' => '#'],
['label' => 'Docs', 'href' => '#'],
['label' => 'Blog', 'href' => '#'],
];
$pill = $shape === 'pill';
@endphp
<header
x-data="{ open: false }"
{{ $attributes->merge([
'data-slot' => 'header-01',
'class' => $pill
? 'sticky top-0 z-40 w-full bg-background text-foreground'
: 'sticky top-0 z-40 w-full border-b border-border bg-background/90 text-foreground backdrop-blur',
]) }}
>
<nav
@class([
'mx-auto flex items-center justify-between gap-4',
'mt-4 max-w-3xl rounded-full border border-border bg-card/80 px-4 py-2 shadow-lg backdrop-blur ps-6' => $pill,
'max-w-7xl px-4 py-4 sm:px-6 lg:px-8' => ! $pill,
])
aria-label="{{ __('Main') }}"
>
<x-ui.brand :href="$brandHref" :label="$brand" :shape="$pill ? 'pill' : 'square'" />
<ul class="hidden items-center gap-2 md:flex">
@foreach ($links as $link)
<li>
<a
href="{{ $link['href'] }}"
@class([
'px-4 py-2 text-sm font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
'rounded-full' => $pill,
'rounded-md' => ! $pill,
])
>
{{ __($link['label']) }}
</a>
</li>
@endforeach
</ul>
<div class="hidden md:block">
<x-ui.button :href="$ctaHref" size="sm" class="{{ $pill ? 'rounded-full' : '' }}">{{ __($cta) }}</x-ui.button>
</div>
<button
type="button"
@class([
'inline-flex items-center justify-center text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring md:hidden',
'size-9 rounded-full' => $pill,
'size-10 rounded-md' => ! $pill,
])
:aria-expanded="open.toString()"
aria-controls="header-01-mobile"
@click="open = ! open"
>
<span class="sr-only">{{ __('Toggle menu') }}</span>
<svg class="size-5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">
<path x-show="! open" d="M4 6h16M4 12h16M4 18h16" stroke-linecap="round" />
<path x-show="open" x-cloak d="M6 6l12 12M18 6L6 18" stroke-linecap="round" />
</svg>
</button>
</nav>
<div
id="header-01-mobile"
x-show="open"
x-cloak
x-transition.opacity
@click.outside="open = false"
@keydown.escape.window="open = false"
@class([
'md:hidden',
'mx-auto mt-2 max-w-3xl rounded-lg border border-border bg-card/95 p-6 shadow-lg backdrop-blur' => $pill,
'border-t border-border' => ! $pill,
])
>
<ul @class(['space-y-2', 'px-4 py-4' => ! $pill])>
@foreach ($links as $link)
<li>
<a href="{{ $link['href'] }}" class="block rounded-md px-4 py-2 text-sm font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">
{{ __($link['label']) }}
</a>
</li>
@endforeach
<li class="pt-2">
<x-ui.button :href="$ctaHref" size="sm" class="{{ $pill ? 'w-full rounded-full' : 'w-full' }}">{{ __($cta) }}</x-ui.button>
</li>
</ul>
</div>
</header>
Ownership & lifecycle
Owner, release state, review evidence and adoption for this item.
- Owner
- Platform UI (@JoshJML)
- Current version
-
1.1.2 - Status
- Stable
- License
-
open - Deprecation
- Not deprecated
- Contract
-
v1 - Foundation
-
≥ 1.0.0