Header with Search
Sticky site header with nav links, ⌘K search, mobile menu, and optional GitHub / CTA buttons. Pass plain `links` and `searchResults` lists - no nested config objects.
Embedded preview
Sample nav and search items; open the palette with ⌘K or Ctrl K.
Search
Search the site
Page content
The header stays pinned while you scroll this preview area.
Pass a list of links and searchResults (each with a section for grouping). Press ⌘K or Ctrl K to open search.
embed-example.tsx
1import {2 HeaderWithSearch,3 type HeaderLink,4 type HeaderSearchResult,5} from "@/registry/ui/header-with-search";67const demoLinks: HeaderLink[] = [8 { label: "Docs", href: "/docs" },9 { label: "Components", href: "/components" },10 { label: "Blocks", href: "/blocks" },11 { label: "Changelog", href: "/docs/changelog" },12];1314const demoSearchResults: HeaderSearchResult[] = [15 { title: "Getting started", href: "/docs", section: "Docs" },16 { title: "Installation", href: "/docs/installation", section: "Docs" },17 {18 title: "Line charts",19 href: "/components/line-charts",20 section: "Components",21 description: "Charts",22 },23 {24 title: "Header with search",25 href: "/components/header-with-search",26 section: "Components",27 description: "Navigation",28 },29 {30 title: "Chat UI 01",31 href: "/blocks/chat-ui-01",32 section: "Blocks",33 description: "Communication",34 },35];3637export function HeaderWithSearchEmbedExample() {38 return (39 <div className="w-full space-y-3">40 <div className="relative isolate min-h-[500px] overflow-hidden rounded-lg border bg-linear-to-b from-muted/30 to-background">41 <HeaderWithSearch42 className="absolute! inset-x-0 top-0 z-10"43 siteName="Acme UI"44 links={demoLinks}45 searchResults={demoSearchResults}46 searchPlaceholder="Search docs, components, blocks…"47 githubUrl="https://github.com"48 ctaText="Get Started"49 ctaHref="/docs"50 />51 <div className="space-y-3 px-6 pb-6 pt-20">52 <div className="space-y-1">53 <p className="text-sm font-medium text-foreground">Page content</p>54 <p className="text-sm text-muted-foreground">55 The header stays pinned while you scroll this preview area.56 </p>57 </div>58 <div className="grid gap-2 sm:grid-cols-2">59 {["Overview", "Settings", "Billing", "Team"].map((label) => (60 <div61 key={label}62 className="h-16 rounded-md border border-dashed bg-muted/40"63 aria-hidden64 />65 ))}66 </div>67 </div>68 </div>69 <p className="text-xs text-muted-foreground">70 Pass a list of <code className="text-foreground">links</code> and{" "}71 <code className="text-foreground">searchResults</code> (each with a{" "}72 <code className="text-foreground">section</code> for grouping). Press{" "}73 <kbd className="rounded border bg-muted px-1.5 py-0.5 font-mono">74 ⌘K75 </kbd>{" "}76 or{" "}77 <kbd className="rounded border bg-muted px-1.5 py-0.5 font-mono">78 Ctrl K79 </kbd>{" "}80 to open search.81 </p>82 </div>83 );84}
Minimal
Minimal header with search
Search
Search the site
minimal-example.tsx
1import {2 HeaderWithSearch,3 type HeaderLink,4 type HeaderSearchResult,5} from "@/registry/ui/header-with-search";67const demoLinks: HeaderLink[] = [8 { label: "Docs", href: "/docs" },9 { label: "Components", href: "/components" },10 { label: "Blocks", href: "/blocks" },11 { label: "Changelog", href: "/docs/changelog" },12];1314const demoSearchResults: HeaderSearchResult[] = [15 { title: "Getting started", href: "/docs", section: "Docs" },16 { title: "Installation", href: "/docs/installation", section: "Docs" },17 {18 title: "Line charts",19 href: "/components/line-charts",20 section: "Components",21 description: "Charts",22 },23 {24 title: "Header with search",25 href: "/components/header-with-search",26 section: "Components",27 description: "Navigation",28 },29 {30 title: "Chat UI 01",31 href: "/blocks/chat-ui-01",32 section: "Blocks",33 description: "Communication",34 },35];3637export function HeaderWithSearchMinimalExample() {38 return (39 <div className="w-full space-y-3">40 <HeaderWithSearch41 className="absolute! inset-x-0 top-0 z-10"42 siteName="Acme UI"43 links={demoLinks}44 searchResults={demoSearchResults}45 />46 </div>47 );48}
Installation & source
Install via the shadcn CLI or copy the registry files manually.
bash
npx shadcn@latest add @tt-ui/header-with-search
Props
| Name | Type | Default | Description |
|---|---|---|---|
| siteName | string | - | Site or product name (shown as text, or logo alt text) |
| links | HeaderLink[] | - | Nav items: `{ label, href }` - current page highlighting is automatic |
| searchResults | HeaderSearchResult[] | - | Search rows: `{ title, href, section }` plus optional `description` |
| searchPlaceholder | string | "Search…" | Placeholder on the search button and in the search dialog |
| logo | { src: string; width?: number; height?: number } | undefined | Optional image instead of the site name text |
| githubUrl / ctaHref / ctaText | string | undefined | Optional GitHub icon link and primary CTA button |
| leftSlot / rightSlot | ReactNode | undefined | Extra controls (e.g. sidebar toggle before the brand, sign-in or theme toggle on the right) |