@objectifthunes/whiteboard
NAVIGATION

Navbar

The horizontal app bar: brand, primary nav, a centre search slot, actions. Links collapse behind a burger under 880px.


SOURCE
import { Navbar, NavbarBrand, activeNavHref, type NavItem } from '@objectifthunes/whiteboard'
import Link from 'next/link'

const ITEMS: NavItem[] = [
  { href: '/inbox', name: 'Inbox', badge: 12 },
  { href: '/invoices', name: 'Invoices' },
]

<Navbar
  brand={<NavbarBrand mark="◈" name="My Whiteboard" tag="pro" />}
  items={ITEMS}
  activeHref={activeNavHref(ITEMS, pathname)}
  renderLink={(item, props) => <Link {...props} href={item.href} />}
  search={<SearchBar value={q} onChange={setQ} label="" placeholder="Search invoices…" />}
  actions={<><ThemeToggle theme={theme} onToggle={toggleTheme} /><UserMenu name={user.name}>…</UserMenu></>}
/>
NOTES

Deliberately the same item shape and the same renderLink contract as Sidebar, so moving a product from a top bar to a sidebar (or back) is a layout change and not a rewrite. Next.js users pass renderLink={(item, props) => <Link {...props} href={item.href} />}.

activeNavHref picks the longest matching href, so /settings/billing activates "Billing" and not also "Settings". It is the flat-list twin of activeSidebarHref.

The centre search slot absorbs the spare width, which is what keeps the brand hard left and the actions hard right at any window size. Under 880px the links collapse behind a burger while the actions stay put, so the bar never wraps to two lines.

Use this when navigation is shallow enough for one line. When it is deep or grouped, reach for DashboardShell with a Sidebar instead.