Skip to content
Klarhimmel UI

Navbar, search

Navbar, search previewNavbar, search preview

Install

npx shadcn add https://ui.klarhimmel.com/r/navbar-search.json
DetailsAbout, usage, props and more

A shop header: the brand, a wide rounded search field, round account and basket buttons, then a row of category links under a rule.

Import

Import

import Block from '@/components/klarhimmel/blocks/navbar-search';
Also called
  • navigation/search
  • header/search
About
A shop header: the brand, a wide rounded search field, round account and basket buttons, then a row of category links under a rule. On a phone the search drops to its own full-width line and the links wrap.
Category
The bar at the top of every page: brand, links, one action. New project? Set it up once: /get-started/installation.

Notes

When to use it

A shop header with a wide search field, round account and basket buttons and a row of category links. Choose navbar-simple when the site has no catalogue to search, and navbar-menu when the links need dropdowns.

Writing for it

- The search form submits a plain GET to its action address with the words in q, so point the action at the page that lists results and it works with no script. - Name each round button for what it opens, such as account or basket, because the label is the only text a screen reader gets for an icon. - Keep the category row to the handful of departments people actually shop by, since it wraps onto more lines instead of folding into a menu.

Watch out for

On a phone the search drops to its own full-width line and the category links wrap beneath it, so a long row of categories makes the header tall. Test it at 390 px before adding a ninth link.

Usage

The block in a page, with its default content (long lists shortened). Every prop is in the table below.

section.tsx
import { Theme } from '@/components/klarhimmel/theme/style';
import { BlockSurface } from '@/components/klarhimmel/blocks/surface';
import NavbarSearch from '@/components/klarhimmel/blocks/navbar-search';

export default function Section() {
  return (
    <Theme theme="brand">
      <BlockSurface>
        <NavbarSearch props={{
          "brand": "Write the business name",
          "search": {
            "label": "Name the search field for screen readers",
            "placeholder": "Say what to search for",
            "href": "/search"
          },
          "actions": [
            {
              "icon": "account",
              "label": "Name the account page",
              "href": "#account"
            },
            {
              "icon": "basket",
              "label": "Name the basket page",
              "href": "#basket"
            }
          ],
          "links": [
            {
              "label": "Name the first category",
              "href": "#first"
            },
            {
              "label": "Name the second category",
              "href": "#second"
            },
            {
              "label": "Name the third category",
              "href": "#third"
            },
            {
              "label": "Name the fourth category",
              "href": "#fourth"
            },
            {
              "label": "Name the fifth category",
              "href": "#fifth"
            }
          ],
          "linksLabel": "Name the category row"
        }} />
      </BlockSurface>
    </Theme>
  );
}

Props

The type, default and text limit of every prop. On a real page, over-limit text is kept and checkSections flags it (Installation, Check a page before you ship); this live preview shows the default until it fits. The panel above edits all props.

PropTypeDefaultDescription
brandstring'Write the business name'Text, up to 40 characters.
mark{ paths, viewBox, src }-Fields: paths (optional), viewBox (optional), src (optional). Optional; empty is not rendered.
brandHrefstring-Text, up to 300 characters. Optional; empty is not rendered.
search{ label, placeholder, href }{…}Fields: label, placeholder, href.
actions{ icon, label, href }[]2 itemsList of up to 3. Each item: icon ('account' | 'basket' | 'heart'), label, href.
linksLink[]5 itemsList of 1 to 10.
linksLabelstring'Name the category row'Text, up to 60 characters.