Header (Topbar)

July 6, 2026 · View on GitHub

Application topbar. Three-section layout (left / center / right) with optional logo, inline nav, search slot, notifications, theme toggle, CTA, and user menu.

Contract

<kp-header> renders a sticky-ready topbar with three sections:

  • Left — logo + main navigation
  • Center — search (projection slot [kpHeaderSearch] or placeholder with [showSearch]="true")
  • Right — theme toggle · notifications · CTA · user menu

Everything is toggleable via boolean inputs; the layout collapses cleanly when sections are hidden.

API

Inputs

NameTypeDefaultDescription
size'sm' | 'md' | 'lg''md'Topbar height (48 / 64 / 80)
appearance'light' | 'dark''light'Light or dark surface
showLogobooleantrueShow the default logo mark + title (or replace via [kpHeaderLogo])
logoTextstring'Kanso Protocol'Title next to the logo mark
showMainNavbooleantrueRender the inline nav from navItems
navItemsKpHeaderNavItem[][]{ label, href?, active? } — renders as links
showSearchbooleanfalseRender built-in search placeholder; override with [kpHeaderSearch] slot
searchPlaceholderstring'Search anything...'
showThemeTogglebooleanfalse
showNotificationsbooleantrue
notificationsCountstring | number | nullnullBadge number; no badge when null
showCtabooleanfalseProminent right-side action
ctaLabelstring'Get started'
showUserMenubooleantrue
userName, userRole, userInitialsstring | nullnullUser block data
showUserStatusbooleanfalsePresence dot on the user avatar

Outputs

NameFires when
themeToggleTheme button clicked
notificationsClickBell clicked
ctaClickCTA clicked
userMenuClickUser block clicked

Projection slots

SelectorSlot
[kpHeaderLogo]Replace the default logo mark + title
[kpHeaderSearch]Custom search (takes precedence over [showSearch])
[kpHeaderActions]Extra buttons before the user menu

Composition recipes

RecipeConfig
SaaS defaultnav + search + notifications + user menu
Admin panelnav + notifications + user menu (no search)
Marketingsize="lg" · nav + CTA; no avatar, notifications, or search
Minimallogo + user menu only

Do / Don't

Do

  • Pick one size per app (most use md). Switching sizes per route is disorienting.
  • Use appearance="dark" deliberately — e.g. dark-themed admin. Don't switch it based on theme toggle alone (use semantic tokens).
  • Wire notificationsClick / userMenuClick to open DropdownMenu / NotificationCenter patterns.

Don't

  • Don't stuff more than 4–5 nav items inline. Group under a secondary menu.
  • Don't put marketing-style CTAs ("Upgrade") in a logged-in SaaS header by default — reserve for paywall states.
  • Don't hide the user menu in the default app state. If you're logged in, your avatar belongs there.

Accessibility

  • role="banner" on the host.
  • Nav carries aria-label="Primary"; active item has aria-current="page".
  • Notification bell exposes the count via aria-live="polite".

References

Changelog

  • 0.1.0 — Initial release. 3 sizes × 2 appearances, all sections toggleable, data-driven nav.