Skip to documentation content

Navigation blocks

Website headers with a desktop menu, a full-screen mobile menu, and one clear action.

Three headers for three kinds of site. Each one turns into a full-screen menu on a phone. The close button lands where the menu button was, focus moves into the menu and returns when it closes, and every row is at least 44 pixels tall.

Product navigation

The header most software needs. The menu has two columns with aligned links and one quiet line underneath, so it reads as an index instead of a wall of tiles.

npx honestui@latest add navigation-product
navigation-product.tsx
"use client"

import * as React from "react"

import { cn } from "@/lib/utils"
import { TextLink } from "@/components/marketing/foundation/action-group"
import { RectoLogo } from "@/components/marketing/foundation/example-brands"
import { MobileMenu } from "@/components/marketing/foundation/mobile-menu"
import { MarketingContainer } from "@/components/marketing/foundation/section"
import type {
  MarketingAction,
  MarketingLink,
} from "@/components/marketing/foundation/types"
import { Button } from "@/components/ui/button"
import {
  NavigationMenu,
  NavigationMenuContent,
  NavigationMenuItem,
  NavigationMenuLink,
  NavigationMenuList,
  NavigationMenuTrigger,
} from "@/components/ui/navigation-menu"

interface NavigationProductMenu {
  label: string
  groups: { label: string; links: (MarketingLink & { description: string })[] }[]
  /** One line under the columns. */
  note?: { text: string; link: MarketingLink }
}

interface NavigationProductProps {
  logo?: React.ReactNode
  homeHref?: string
  menu?: NavigationProductMenu
  links?: MarketingLink[]
  logIn?: MarketingLink
  action?: MarketingAction
  /** Keeps the bar at the top while the page scrolls. */
  sticky?: boolean
  /** An anchor for links within the page. */
  id?: string
  className?: string
}

const DEFAULT_MENU: NavigationProductMenu = {
  label: "Product",
  groups: [
    {
      label: "Write and review",
      links: [
        { label: "Documents", href: "#documents", description: "Draft, comment and track changes" },
        { label: "Versions", href: "#versions", description: "Compare any two, word by word" },
        { label: "Search", href: "#search", description: "Find the sentence, not the file" },
      ],
    },
    {
      label: "Decide and publish",
      links: [
        { label: "Approvals", href: "#approvals", description: "Ask, answer and lock a version" },
        { label: "Schedules", href: "#schedules", description: "Plan who reads when" },
        { label: "Audit record", href: "#audit", description: "Who approved what, and when" },
      ],
    },
  ],
  note: {
    text: "New in November: reviewers can approve from email.",
    link: { label: "See what changed", href: "#changelog" },
  },
}

const DEFAULT_LINKS: MarketingLink[] = [
  { label: "Customers", href: "#customers" },
  { label: "Pricing", href: "#pricing" },
  { label: "Guides", href: "#guides" },
]

const triggerClass = "min-h-9 px-3 [font-size:0.875rem] [font-weight:450]"

/** Wordmark, a few links, one menu worth opening, and one thing to do. */
export function NavigationProduct({
  logo = <RectoLogo />,
  homeHref = "/",
  menu = DEFAULT_MENU,
  links = DEFAULT_LINKS,
  logIn = { label: "Log in", href: "#login" },
  action = { label: "Start free", href: "#start" },
  sticky = false,
  id,
  className,
}: NavigationProductProps) {
  return (
    <header
      data-slot="marketing-navigation"
      id={id}
      className={cn(
        "z-40 w-full bg-(--mkt-paper) text-(--mkt-ink)",
        sticky && "sticky top-0",
        className
      )}
    >
      <MarketingContainer className="flex h-16 items-center gap-6 lg:grid lg:h-18 lg:grid-cols-[1fr_auto_1fr]">
        <a href={homeHref} className="mkt-link inline-flex justify-self-start" data-touch="">
          {logo}
        </a>

        <NavigationMenu className="hidden lg:block" aria-label="Main">
          <NavigationMenuList>
            <NavigationMenuItem>
              <NavigationMenuTrigger className={triggerClass}>{menu.label}</NavigationMenuTrigger>
              <NavigationMenuContent className="p-0 sm:w-[41rem]">
                <div className="grid grid-cols-2 gap-x-4 p-4">
                  {menu.groups.map((group) => (
                    <div key={group.label}>
                      <p className="m-0 px-3 pt-1.5 pb-2 text-[0.8125rem] leading-5 text-(--mkt-ink-soft)">
                        {group.label}
                      </p>
                      <ul className="m-0 grid list-none gap-0.5 p-0">
                        {group.links.map((link) => (
                          <li key={link.label}>
                            <NavigationMenuLink href={link.href} className="gap-0 px-3 py-2.5">
                              <span className="text-[0.9375rem] leading-6 tracking-[-0.008em] [font-weight:500]">
                                {link.label}
                              </span>
                              <span className="text-[0.8125rem] leading-5 text-(--mkt-ink-soft)">
                                {link.description}
                              </span>
                            </NavigationMenuLink>
                          </li>
                        ))}
                      </ul>
                    </div>
                  ))}
                </div>
                {menu.note && (
                  <div className="flex items-center justify-between gap-6 border-t-[0.5px] border-(--mkt-line-strong) px-7 py-3.5">
                    <p className="m-0 text-[0.8125rem] leading-5 text-(--mkt-ink-soft)">
                      {menu.note.text}
                    </p>
                    <TextLink link={menu.note.link} className="text-[0.8125rem]" />
                  </div>
                )}
              </NavigationMenuContent>
            </NavigationMenuItem>
            {links.map((link) => (
              <NavigationMenuItem key={link.label}>
                <NavigationMenuLink variant="trigger" href={link.href} className={triggerClass}>
                  {link.label}
                </NavigationMenuLink>
              </NavigationMenuItem>
            ))}
          </NavigationMenuList>
        </NavigationMenu>

        <div className="ms-auto flex items-center gap-1.5 justify-self-end">
          <Button
            variant="ghost"
            className="hidden [font-size:0.875rem] sm:inline-flex"
            render={<a href={logIn.href} />}
          >
            {logIn.label}
          </Button>
          <Button
            variant={action.variant ?? "default"}
            className="[font-size:0.875rem]"
            render={<a href={action.href} />}
          >
            {action.label}
          </Button>
          <div className="-me-3 lg:hidden">
            <MobileMenu
              logo={logo}
              homeHref={homeHref}
              groups={[...menu.groups, { label: "More", links }]}
              actions={[action, logIn]}
            />
          </div>
        </div>
      </MarketingContainer>
    </header>
  )
}

export type { NavigationProductMenu, NavigationProductProps }
DetailGuidance
Use it forSoftware with several product areas and a sign-in.
ContentThree or four links on the bar. Two groups of two to four links in the menu, with descriptions under six words.
OptionalThe menu note, the log in link, and sticky.
StatesMenu opens on hover, click, Enter and Down Arrow. Escape closes it and returns focus. The mobile menu traps focus.
RequiresFoundation, Button, Navigation Menu, Sheet
Goes well withCentered hero with wide product preview, Split hero with product preview, Quiet logo row

Floating navigation

A bar that keeps clear of the page edge. At rest it has a hairline and almost no shadow. Once the page scrolls, the shadow deepens and nothing resizes.

npx honestui@latest add navigation-floating
navigation-floating.tsx
"use client"

import * as React from "react"

import { cn } from "@/lib/utils"
import { RectoLogo } from "@/components/marketing/foundation/example-brands"
import { MobileMenu } from "@/components/marketing/foundation/mobile-menu"
import { MarketingContainer } from "@/components/marketing/foundation/section"
import type {
  MarketingAction,
  MarketingLink,
} from "@/components/marketing/foundation/types"
import { Button } from "@/components/ui/button"

interface NavigationFloatingProps {
  logo?: React.ReactNode
  homeHref?: string
  links?: MarketingLink[]
  logIn?: MarketingLink
  action?: MarketingAction
  /** An anchor for links within the page. */
  id?: string
  className?: string
}

const DEFAULT_LINKS: MarketingLink[] = [
  { label: "Product", href: "#product" },
  { label: "Customers", href: "#customers" },
  { label: "Pricing", href: "#pricing" },
  { label: "Guides", href: "#guides" },
]

/** True once the page has moved. Read in one place, so the bar never resizes. */
function useScrolled(offset = 12) {
  return React.useSyncExternalStore(
    (notify) => {
      window.addEventListener("scroll", notify, { passive: true })
      return () => window.removeEventListener("scroll", notify)
    },
    () => window.scrollY > offset,
    () => false
  )
}

/** A compact bar that stays clear of the edges and lifts slightly on scroll. */
export function NavigationFloating({
  logo = <RectoLogo />,
  homeHref = "/",
  links = DEFAULT_LINKS,
  logIn = { label: "Log in", href: "#login" },
  action = { label: "Start free", href: "#start" },
  id,
  className,
}: NavigationFloatingProps) {
  const scrolled = useScrolled()

  return (
    <header
      data-slot="marketing-navigation"
      id={id}
      className={cn(
        "pointer-events-none sticky top-0 z-40 w-full pt-3 text-(--mkt-ink) md:pt-5",
        className
      )}
    >
      <MarketingContainer>
        <div
          className={cn(
            "pointer-events-auto mx-auto flex h-14 max-w-[54rem] items-center gap-4 rounded-[calc(var(--mkt-radius-control)+8px)] bg-(--mkt-frame) ps-4 pe-1 transition-shadow duration-300 motion-reduce:transition-none lg:pe-2",
            scrolled
              ? "shadow-[0_0_0_0.5px_var(--mkt-line-strong),0_1px_2px_rgb(0_0_0/0.04),0_10px_28px_-12px_rgb(0_0_0/0.22)]"
              : "shadow-[0_0_0_0.5px_var(--mkt-line-strong),0_1px_2px_rgb(0_0_0/0.03)]"
          )}
        >
          <a href={homeHref} className="mkt-link inline-flex" data-touch="">
            {logo}
          </a>
          <nav aria-label="Main" className="mx-auto hidden lg:block">
            <ul className="m-0 flex list-none gap-1 p-0">
              {links.map((link) => (
                <li key={link.label}>
                  <a
                    href={link.href}
                    className="mkt-link inline-flex h-9 items-center rounded-(--mkt-radius-control) px-3 text-[0.875rem] leading-5 tracking-[-0.004em] text-(--mkt-ink-soft) [font-weight:450] hover:text-(--mkt-ink)"
                  >
                    {link.label}
                  </a>
                </li>
              ))}
            </ul>
          </nav>
          <div className="ms-auto flex items-center gap-1 lg:ms-0">
            <Button
              variant="ghost"
              className="hidden [font-size:0.875rem] lg:inline-flex"
              render={<a href={logIn.href} />}
            >
              {logIn.label}
            </Button>
            <Button
              variant={action.variant ?? "default"}
              className="[font-size:0.875rem]"
              render={<a href={action.href} />}
            >
              {action.label}
            </Button>
            <div className="lg:hidden">
              <MobileMenu
                logo={logo}
                homeHref={homeHref}
                groups={[{ label: "", links }]}
                actions={[action, logIn]}
              />
            </div>
          </div>
        </div>
      </MarketingContainer>
    </header>
  )
}

export type { NavigationFloatingProps }
DetailGuidance
Use it forA centered hero or a page that opens with a large image.
ContentUp to four links and one action.
OptionalThe log in link.
StatesRest and scrolled surfaces. The bar is sticky and lets clicks through on either side.
RequiresFoundation, Button, Sheet
Goes well withCentered hero with wide product preview, Editorial statement hero

Editorial navigation

A large wordmark, two links, and a menu set at headline size. The bar shares its columns with the editorial hero, so the links sit above the hero's paragraph.

npx honestui@latest add navigation-editorial
navigation-editorial.tsx
"use client"

import * as React from "react"

import { cn } from "@/lib/utils"
import { FerrowLogo } from "@/components/marketing/foundation/example-brands"
import { MobileMenu } from "@/components/marketing/foundation/mobile-menu"
import { MarketingContainer } from "@/components/marketing/foundation/section"
import type { MarketingLink } from "@/components/marketing/foundation/types"

interface NavigationEditorialProps {
  logo?: React.ReactNode
  homeHref?: string
  /** Two or three links that stay on the bar. */
  links?: MarketingLink[]
  contact?: MarketingLink
  /** Every page, set large in the full-screen menu. */
  menuLinks?: MarketingLink[]
  email?: string
  address?: string
  /** An anchor for links within the page. */
  id?: string
  className?: string
}

const DEFAULT_LINKS: MarketingLink[] = [
  { label: "Work", href: "#work" },
  { label: "Studio", href: "#studio" },
]

const DEFAULT_MENU: MarketingLink[] = [
  { label: "Work", href: "#work" },
  { label: "Studio", href: "#studio" },
  { label: "Services", href: "#services" },
  { label: "Journal", href: "#journal" },
  { label: "Contact", href: "#contact" },
]

/** A prominent wordmark, very few links, and a menu with room to breathe. */
export function NavigationEditorial({
  logo = <FerrowLogo className="text-[1.625rem]" />,
  homeHref = "/",
  links = DEFAULT_LINKS,
  contact = { label: "Start a project", href: "#contact" },
  menuLinks = DEFAULT_MENU,
  email = "hello@ferrow.example",
  address = "Rua do Almada 412, Porto",
  id,
  className,
}: NavigationEditorialProps) {
  const linkClass =
    "mkt-link inline-flex h-11 items-center text-[0.9375rem] leading-6 tracking-[-0.008em]"

  return (
    <header
      data-slot="marketing-navigation"
      id={id}
      className={cn("z-40 w-full bg-(--mkt-paper) text-(--mkt-ink)", className)}
    >
      <MarketingContainer
        size="wide"
        className="flex h-16 items-center justify-between gap-6 lg:grid lg:h-22 lg:grid-cols-12 lg:gap-x-(--mkt-column-gap)"
      >
        <a href={homeHref} className="mkt-link inline-flex justify-self-start lg:col-span-8" data-touch="">
          {logo}
        </a>
        <div className="flex items-center justify-between gap-7 lg:col-span-4 lg:ps-4">
          <nav aria-label="Main" className="hidden lg:block">
            <ul className="m-0 flex list-none gap-7 p-0">
              {links.map((link) => (
                <li key={link.label}>
                  <a href={link.href} className={linkClass} data-tone="soft">
                    {link.label}
                  </a>
                </li>
              ))}
              <li>
                <a href={contact.href} className={linkClass} data-underline="">
                  {contact.label}
                </a>
              </li>
            </ul>
          </nav>
          <MobileMenu
            logo={logo}
            homeHref={homeHref}
            size="large"
            groups={[{ label: "", links: menuLinks }]}
            trigger={
              <button
                type="button"
                className={cn(
                  linkClass,
                  "-me-2 cursor-pointer border-0 bg-transparent px-2 text-(--mkt-ink) [font-weight:500]"
                )}
              >
                Menu
              </button>
            }
            footer={
              <div className="flex flex-wrap items-baseline justify-between gap-x-8 gap-y-2 border-t-[0.5px] border-(--mkt-line-strong) pt-5">
                <a
                  href={`mailto:${email}`}
                  className="mkt-link py-2 text-[1.125rem] leading-7 tracking-[-0.016em] [overflow-wrap:anywhere]"
                  data-underline=""
                >
                  {email}
                </a>
                <p className="mkt-meta">{address}</p>
              </div>
            }
          />
        </div>
      </MarketingContainer>
    </header>
  )
}

export type { NavigationEditorialProps }
DetailGuidance
Use it forStudios, portfolios and brands with few pages.
ContentTwo links on the bar and up to six in the menu.
OptionalThe email address and street address in the menu.
StatesThe full-screen menu works the same way at every width. Escape and the close button both return focus to Menu.
RequiresFoundation, Button, Sheet
Goes well withEditorial statement hero, Studio footer

Usage

Every prop has a default, so a block renders as soon as it is installed. Pass your own content to replace it.

import { NavigationProduct } from "@/components/marketing/navigation-product"

<NavigationProduct
  logo={<Logo />}
  links={[{ label: "Pricing", href: "/pricing" }]}
  action={{ label: "Start free", href: "/sign-up" }}
  sticky
/>
PropTypeDefaultDescription
logoReactNode–The wordmark. It is also the link home.
menuNavigationProductMenu–The label, link groups, and optional note of the dropdown.
linksMarketingLink[]–Plain links beside the menu.
actionMarketingAction–The one primary action.
stickybooleanfalseKeeps the bar at the top while the page scrolls.