The top bar: brand, links, dropdowns and mega panels, search, theme, account and a call to action. The panels share one box: it opens from under its item and, moving to the next, springs to the new size while the content slides across. Sticky with a blur once you scroll, and a drawer on small screens.
- Marketing site top bar
- Docs header with search
- App header with account
- Mobile menu drawer
Examples
Minimal
Installation
npx knowns-ui@latest add site-headerPaste this into your coding agent (Claude Code, Cursor, Codex). It checks your project, sets up the registry, runs the install and verifies it.
Install Site header from Knowns UI into this project. Work step by step, show me each change, and ask before you edit files outside this project.
Context: Knowns UI (https://ui.knowns.dev) is a shadcn registry. Items land in the project as source files. Docs: https://ui.knowns.dev/docs/site-header
1. Check the project first. Stop and tell me if any of these is missing:
- React 19 and Tailwind CSS v4.
- A components.json at the project root. If there is none, ask me before running `npx knowns-ui@latest init --no-key` (it runs shadcn init when needed, then adds the registries).
2. Run:
```bash
npx knowns-ui@latest add site-header
```
It writes these files:
- lib/knowns/run.ts
- lib/knowns/json.tsx
- lib/knowns/status.ts
- lib/knowns/tone.ts
- lib/knowns/types.ts
- lib/knowns/use-abortable.ts
- lib/knowns/utils.ts
- components/ui/knowns/accordion.tsx
- components/ui/knowns/spinner.tsx
- components/ui/knowns/button.tsx
- lib/knowns/motion.tsx
- lib/knowns/motion-utils.ts
- lib/knowns/home.ts
- lib/knowns/home-utils.ts
- components/ui/knowns/kbd.tsx
- components/ui/knowns/theme-toggle.tsx
- components/ui/knowns/blocks/site/site-header.tsx
- components/ui/knowns/blocks/site/site-utils.ts
and installs these npm packages: clsx@^2.1.1, tailwind-merge@^3.7.0, class-variance-authority@^0.7.1.
3. While it runs:
- It also adds a few @keyframes (all named kn-*) to the global CSS file (globals.css or the file components.json points at). Let it: they only add animations.
- If it asks to overwrite files under lib/knowns/: these are shared by every Knowns UI item. List them, say whether I changed them (check git), and ask me before you answer.
- If it asks to overwrite any other file, show me the diff and ask me.
4. Verify:
- Every file in the list above exists.
- The project type-checks (for example `npx tsc --noEmit`) and the dev build has no new errors.
5. Use it: follow the examples and props on https://ui.knowns.dev/docs/site-header, and ask me if anything about my data is unclear.
If the Knowns UI MCP server is connected (https://ui.knowns.dev/docs/ai-and-mcp), use get_component({ name: "site-header" }) or search_docs for details.
Finish with a short summary: the files you added or changed, the packages you installed, and anything I still need to do.Props
- brand / brandHref / brandLabel
ReactNode / string- Default
"/" - Logo and name, a link home named "<brandLabel> home". On the home page itself, or in a preview frame (HomeFrame), it scrolls back to the top instead and clears the hash.
- onHome
() => void- For an app that switches views in place: the brand calls it (and scrolls to the top) instead of following brandHref.
- nav
NavEntry[]- Default
[] - Links, { kind: "dropdown", items } and { kind: "mega", groups, featured, cards, footer, drawer }. cards are product cards (image, imageDark, label, description, href) in a row under the groups, or the whole panel with no groups. Items take a description, an icon, a count and a badge. footer is a quiet row at the bottom of the panel (text and a link). drawer: "flat" lists the groups in the mobile drawer instead of folding them.
- currentHref
string- Marks the matching top item with an indicator and the exact link with aria-current. Parents match their sub-paths.
- onNavigate
(href, event) => void- Every link click; call preventDefault for client-side routing.
- search
{ onOpen, label?, shortcut?, button? }- A search button (⌘K hint from 1024px) and a Search row in the drawer. Open your Command Menu in onOpen. button: false drops the bar button and keeps the drawer row.
- leading
ReactNode- Before the brand, e.g. a SidebarTrigger that opens your app or docs navigation on small screens.
- theme
{ value: "light" | "dark", onChange }- Our Theme Toggle: the new theme grows from the click in a circle (instant with reduced motion). 44px on touch.
- actions
ReactNode- Icon buttons right after the theme toggle, in its spacing: a GitHub link, notifications. Use the ghost icon Button so they match the toggle.
- account / signIn / cta
ReactNode / { label?, href?, onClick? }- Right side: your UserMenu when signed in, otherwise Sign in; the CTA is primary on marketing.
- variant
"marketing"|"minimal"- Default
"marketing" - 64px with centred links, or 52px with links next to the brand.
- sticky / scrollRoot
boolean / HTMLElement- Default
true / window - Sticky with a blurred background and hairline after 4px of scroll; pass the scrolling element when it is not the window.
- solid
boolean- Default
false - Always show the background and hairline, for app and docs layouts where the header sits on a sidebar.
| Prop | Type | Default | Description |
|---|---|---|---|
| brand / brandHref / brandLabel | ReactNode / string | "/" | Logo and name, a link home named "<brandLabel> home". On the home page itself, or in a preview frame (HomeFrame), it scrolls back to the top instead and clears the hash. |
| onHome | () => void | - | For an app that switches views in place: the brand calls it (and scrolls to the top) instead of following brandHref. |
| nav | NavEntry[] | [] | Links, { kind: "dropdown", items } and { kind: "mega", groups, featured, cards, footer, drawer }. cards are product cards (image, imageDark, label, description, href) in a row under the groups, or the whole panel with no groups. Items take a description, an icon, a count and a badge. footer is a quiet row at the bottom of the panel (text and a link). drawer: "flat" lists the groups in the mobile drawer instead of folding them. |
| currentHref | string | - | Marks the matching top item with an indicator and the exact link with aria-current. Parents match their sub-paths. |
| onNavigate | (href, event) => void | - | Every link click; call preventDefault for client-side routing. |
| search | { onOpen, label?, shortcut?, button? } | - | A search button (⌘K hint from 1024px) and a Search row in the drawer. Open your Command Menu in onOpen. button: false drops the bar button and keeps the drawer row. |
| leading | ReactNode | - | Before the brand, e.g. a SidebarTrigger that opens your app or docs navigation on small screens. |
| theme | { value: "light" | "dark", onChange } | - | Our Theme Toggle: the new theme grows from the click in a circle (instant with reduced motion). 44px on touch. |
| actions | ReactNode | - | Icon buttons right after the theme toggle, in its spacing: a GitHub link, notifications. Use the ghost icon Button so they match the toggle. |
| account / signIn / cta | ReactNode / { label?, href?, onClick? } | - | Right side: your UserMenu when signed in, otherwise Sign in; the CTA is primary on marketing. |
| variant | "marketing" | "minimal" | "marketing" | 64px with centred links, or 52px with links next to the brand. |
| sticky / scrollRoot | boolean / HTMLElement | true / window | Sticky with a blurred background and hairline after 4px of scroll; pass the scrolling element when it is not the window. |
| solid | boolean | false | Always show the background and hairline, for app and docs layouts where the header sits on a sidebar. |
Keyboard: Tab reaches each top item; ← → move between them, ↓ opens a panel and enters it, ↑ ↓ move through its links (↑ from the first returns to the button), Escape closes and gives focus back. On a mouse, panels open on hover after a short pause. Below 768px the links move to a drawer: a modal dialog, so focus stays inside and Escape closes it; groups are accordions, the page behind does not scroll, and the drawer closes if the window grows past the breakpoint.
What it handles
- 01Sticks to the top, transparent at first, and adds a blurred background and a hairline once the page scrolls past 4px, or always with solid.
- 02Marks the current page from currentHref with an underline indicator and aria-current, and calls onNavigate for every link so you can route on the client.
- 03Opens dropdowns and a mega panel of grouped links with icons, descriptions and a featured card, by click, by hover on a mouse, or by the arrow keys.
- 04Moves by keyboard: left and right between top items, down into a panel, up and down through its links, Home and End to the ends, and Escape to close and return focus.
- 05Moves the links into a modal dialog drawer below 768px, with accordion groups, a locked page scroll and focus kept inside.
- 06Shows a search trigger with a kbd hint, a theme toggle, extra icon actions, an account slot or a Sign in link, and a call to action, in a marketing or a minimal variant.
States
- First render
- Nothing. The bar paints in its resting look
- none
- Scrolled
- The background blurs and the hairline appears
- 180ms, ease out
- Panel open or close
- The panel fades and slides down a few pixels
- 120ms, ease out
- Chevron and active indicator
- The chevron turns over and the underline fades and widens
- 180ms, ease out
- Link hover
- The text and background colour change
- 120ms, ease out
- Drawer opens
- The drawer slides in from the right edge
- 280ms, ease out
- Reduced motion
- Panels, indicator and drawer change at once
- 0ms
| State | What moves | Timing |
|---|---|---|
| First render | Nothing. The bar paints in its resting look | none |
| Scrolled | The background blurs and the hairline appears | 180ms, ease out |
| Panel open or close | The panel fades and slides down a few pixels | 120ms, ease out |
| Chevron and active indicator | The chevron turns over and the underline fades and widens | 180ms, ease out |
| Link hover | The text and background colour change | 120ms, ease out |
| Drawer opens | The drawer slides in from the right edge | 280ms, ease out |
| Reduced motion | Panels, indicator and drawer change at once | 0ms |
Works with
- Theme toggleInstalled with it. The theme prop mounts it and reveals the new theme with a circle from the click.
- AccordionInstalled with it. The drawer groups its links as accordion items.
- Command menuPairs with it: search.onOpen is where you open your CommandMenu.
- User menuPairs with it: pass it as account when the visitor is signed in.
When to use
When to use
- The top bar of a marketing site or app: links, a mega panel for products, search, theme, account and a call to action.
- Sites that need a proper small-screen menu: a drawer with grouped links, focus kept inside and the page locked behind it.
When not to use
- The title row of one app page, with breadcrumbs and actions: use Page Header.
- Navigation between sections of a settings area: use Settings.
Using with AI
Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:
- Add the Knowns UI Site Header to my app and wire it to my own data.
- I need the top bar of a marketing site or app: links, a mega panel for products, search, theme, account and a call to action. Set that up with the Knowns UI Site Header.
- Which Site Header props do I need for a minimal setup? Show me a short example.
With the server connected, your assistant calls get_component({ name: "site-header" }) and search_docs({ query: "site header" }).