Skip to main content

Navigation Bar

The site header on every page, as a header landmark. It holds a skip link first, the green brand strip, an optional utility row, then the bar: the logo as a home link, the Navigation Menu, icon Buttons, the one action and, below the inline threshold, the drawer's menu Button.

import {
  NavigationBar,
  NavigationBarUtility,
  NavigationBarUtilityLink,
} from '@fairgarden/design/navigation/navigation-bar'

The bar is an opaque kind="band" Ground: the page ground it sits in (paper, white or the page's one pastel), or preset="night" only directly over the night media hero. It is 56 px tall (64 px from --lg-n-above), with a full-bleed --role-rule bottom rule, and its content is capped at --fgd-container-content; with wide it runs to --fgd-container-wide, to meet a wide page frame such as the Docs Layout's columns. The logo is a plain home link unless you pass renderLink, such as (href) => <NextLink href={href} />, which the drawer's bar repeats. Inside the Docs Layout, which renders the page's skip link, the bar renders none. Panels attach under that rule. currentPath flows to the menu, the drawer and the utility links, which mark the current page and the parent of the current page by URL path.

The site header

From --fgd-nav-inline-n-above (1024 px by default, a build-time custom media) the inline menu and the 36 px utility row show. Below it they are replaced by the drawer's menu Button, and the utility links move to the drawer footer. Items never wrap. At the threshold the logo, items, search, action and gaps must fit the content container (944 px at 1024 px). Overflow goes to the utility row, then to a final "More" item with a dropdown panel, never a hamburger. A site over budget sets the custom media to 1440 px. Below 768 px the bar keeps the logo, the search trigger and the menu Button, and the action moves to the top of the drawer footer; below 360 px the "Menu" label drops to the icon. The logo gives way last: where the bar is too narrow for it, it shrinks inside its 44 px target rather than push the controls out, so the bar never overflows. A lockup drops its wordmark there and leaves the mark, as this one does below about 410 px.

'use client'

import * as React from 'react'
import { Button } from '@fairgarden/design/actions/button'
import {
  NavDrawer,
  NavDrawerFooter,
  NavDrawerGroup,
  NavDrawerLink,
} from '@fairgarden/design/navigation/nav-drawer'
import {
  NavigationBar,
  NavigationBarUtility,
  NavigationBarUtilityLink,
} from '@fairgarden/design/navigation/navigation-bar'
import {
  NavigationMenu,
  NavigationMenuContent,
  NavigationMenuFeatured,
  NavigationMenuGroup,
  NavigationMenuItem,
  NavigationMenuLink,
  NavigationMenuPromo,
  NavigationMenuTrigger,
} from '@fairgarden/design/navigation/navigation-menu'
import { Search } from '@fairgarden/design/forms/search'
import { Lockup } from '@/components/Logo'
import { photo } from './photo'
import styles from './header.module.css'

/**
 * The full header on a page in Programs › Garden Programs: skip link, brand
 * strip, utility row, logo, the inline menu from 1024 px, search, the one
 * action, and the drawer below 1024 px. The docs show it in a frame that is
 * its own viewport, so the bar answers to the frame's width; open the full
 * page to see the inline menu at the window's width.
 */
export function NavigationBarHeader() {
  return (
    <div className={styles.page}>
      <NavigationBar
        logo={<Lockup />}
        logoLabel="FairGarden home"
        currentPath="/programs/gardens"
        skipHref="#header-demo-content"
        utility={
          <NavigationBarUtility>
            <NavigationBarUtilityLink href="/about">About</NavigationBarUtilityLink>
            <NavigationBarUtilityLink href="/jobs">Job Board</NavigationBarUtilityLink>
            <NavigationBarUtilityLink href="/newsroom">Newsroom</NavigationBarUtilityLink>
            <NavigationBarUtilityLink href="/blog">Blog</NavigationBarUtilityLink>
          </NavigationBarUtility>
        }
        search={<Search kind="trigger" label="Search FairGarden" />}
        action={
          <Button variant="solid" size="sm" nativeButton={false} render={<a href="/donate" />}>
            Donate
          </Button>
        }
        drawer={
          <NavDrawer
            footer={
              <NavDrawerFooter
                action={
                  <Button variant="solid" size="lg" nativeButton={false} render={<a href="/donate" />}>
                    Donate
                  </Button>
                }
              >
                <NavDrawerLink href="/about">About</NavDrawerLink>
                <NavDrawerLink href="/newsroom">Newsroom</NavDrawerLink>
                <NavDrawerLink href="/accessibility">Accessibility settings</NavDrawerLink>
              </NavDrawerFooter>
            }
          >
            <NavDrawerGroup label="Our Work">
              <NavDrawerLink href="/our-work">Our work</NavDrawerLink>
              <NavDrawerLink href="/our-work/stewardship">Stewardship</NavDrawerLink>
              <NavDrawerLink href="/our-work/priorities">Priorities</NavDrawerLink>
            </NavDrawerGroup>
            <NavDrawerGroup label="Programs">
              <NavDrawerLink href="/programs">Programs</NavDrawerLink>
              <NavDrawerLink href="/programs/gardens">Garden programs</NavDrawerLink>
              <NavDrawerLink href="/programs/impact">Our impact</NavDrawerLink>
            </NavDrawerGroup>
            <NavDrawerGroup label="Get Involved">
              <NavDrawerLink href="/get-involved">Get involved</NavDrawerLink>
              <NavDrawerLink href="/get-involved/volunteer">Volunteer</NavDrawerLink>
              <NavDrawerLink href="/get-involved/give">Give</NavDrawerLink>
            </NavDrawerGroup>
            <NavDrawerLink href="/find-a-garden">Find a Garden</NavDrawerLink>
          </NavDrawer>
        }
      >
        <NavigationMenu>
          <NavigationMenuItem>
            <NavigationMenuTrigger section="/our-work">Our Work</NavigationMenuTrigger>
            <NavigationMenuContent
              kind="overview"
              featured={
                <NavigationMenuFeatured
                  href="/our-work"
                  description="Why shared gardens make stronger towns."
                >
                  Our Work
                </NavigationMenuFeatured>
              }
              promo={
                <NavigationMenuPromo
                  href="/our-work/grown-close-to-home"
                  title="Grown Close to Home"
                  image={<img src={photo} alt="Raised beds on a hillside above a river valley" />}
                >
                  Shared plots cool our streets, feed our families and bring neighbors out.
                </NavigationMenuPromo>
              }
            >
              <NavigationMenuGroup heading="Stewardship" href="/our-work/stewardship">
                <NavigationMenuLink href="/our-work/stewardship/why-grow">Why grow together</NavigationMenuLink>
                <NavigationMenuLink href="/our-work/stewardship/agreements">
                  Garden land agreements
                </NavigationMenuLink>
              </NavigationMenuGroup>
              <NavigationMenuGroup heading="Priorities" href="/our-work/priorities">
                <NavigationMenuLink href="/our-work/priorities/climate">Climate</NavigationMenuLink>
                <NavigationMenuLink href="/our-work/priorities/water">Clean water</NavigationMenuLink>
                <NavigationMenuLink href="/our-work/priorities/food">Local food</NavigationMenuLink>
              </NavigationMenuGroup>
            </NavigationMenuContent>
          </NavigationMenuItem>

          <NavigationMenuItem>
            <NavigationMenuTrigger section="/programs">Programs</NavigationMenuTrigger>
            <NavigationMenuContent
              kind="overview"
              featured={
                <NavigationMenuFeatured
                  href="/programs"
                  description="We help neighbors start, tend and keep the gardens they love."
                >
                  Programs
                </NavigationMenuFeatured>
              }
            >
              <NavigationMenuGroup heading="Garden Programs" href="/programs/gardens">
                <NavigationMenuLink href="/programs/gardens/plot-matching">Plot matching</NavigationMenuLink>
                <NavigationMenuLink href="/programs/gardens/seed-library">Seed library</NavigationMenuLink>
              </NavigationMenuGroup>
              <NavigationMenuGroup heading="Our Impact" href="/programs/impact">
                <NavigationMenuLink href="/programs/impact/harvest">Annual harvest count</NavigationMenuLink>
                <NavigationMenuLink href="/programs/impact/stories">Garden stories</NavigationMenuLink>
              </NavigationMenuGroup>
              <NavigationMenuGroup heading="Training" href="/programs/training">
                <NavigationMenuLink href="/programs/training/courses">Courses</NavigationMenuLink>
                <NavigationMenuLink href="/programs/training/gathering">Annual gathering</NavigationMenuLink>
              </NavigationMenuGroup>
            </NavigationMenuContent>
          </NavigationMenuItem>

          <NavigationMenuItem>
            <NavigationMenuTrigger section="/get-involved">Get Involved</NavigationMenuTrigger>
            <NavigationMenuContent>
              <NavigationMenuLink href="/get-involved/volunteer">Volunteer</NavigationMenuLink>
              <NavigationMenuLink href="/get-involved/share-land">Share your land</NavigationMenuLink>
              <NavigationMenuLink href="/get-involved/give">Give</NavigationMenuLink>
            </NavigationMenuContent>
          </NavigationMenuItem>

          <NavigationMenuItem>
            <NavigationMenuLink href="/find-a-garden">Find a Garden</NavigationMenuLink>
          </NavigationMenuItem>
        </NavigationMenu>
      </NavigationBar>
      <div id="header-demo-content" className={styles.content} tabIndex={-1}>
        Page content starts here.
      </div>
    </div>
  )
}

Ruled, masthead and compact

Ruled, masthead and compact

ruled splits the items with vertical rules. masthead stacks a wordmark row over the caps nav row, ruled above and below. compact is the docked header at the same height: the utility row and brand drawing drop, and the triggers, search and action stay.

The header is static by default (dock="none"). dock="pinned" docks it after 50vh of scroll, and it stays until its own place scrolls back into view. dock="swap" works with the sticky section bar: pass a zero-height sentinelRef at the bar's in-flow position. Once it passes the viewport top, upward scroll brings the header back in place of the bar, and downward scroll restores the bar. Hide the bar while onDockChange reports true, so the two never stack. While docked, the header turns compact and takes the top edge on --layer-2, swapped in by a --fgd-duration-quick clip cut that is instant under reduced motion.

'use client'

import * as React from 'react'
import { Button } from '@fairgarden/design/actions/button'
import { NavigationBar } from '@fairgarden/design/navigation/navigation-bar'
import {
  NavigationMenu,
  NavigationMenuItem,
  NavigationMenuLink,
} from '@fairgarden/design/navigation/navigation-menu'
import { Lockup } from '@/components/Logo'
import styles from './variants.module.css'

const sections = [
  { href: '/our-work', label: 'Our Work' },
  { href: '/programs', label: 'Programs' },
  { href: '/get-involved', label: 'Get Involved' },
]

function Items() {
  return (
    <NavigationMenu>
      {sections.map((section) => (
        <NavigationMenuItem key={section.href}>
          <NavigationMenuLink href={section.href}>{section.label}</NavigationMenuLink>
        </NavigationMenuItem>
      ))}
    </NavigationMenu>
  )
}

const action = (
  <Button variant="solid" size="sm">
    Donate
  </Button>
)

/** The ruled cells, the stacked masthead and the compact (docked) header, on the tide page ground. */
export function NavigationBarVariants() {
  return (
    <div className={styles.stack}>
      <NavigationBar ruled preset="tide" logo={<Lockup />} logoLabel="FairGarden home" currentPath="/get-involved" action={action}>
        <Items />
      </NavigationBar>
      <NavigationBar masthead logo={<Lockup />} logoLabel="FairGarden home" currentPath="/programs/gardens" action={action}>
        <Items />
      </NavigationBar>
      <NavigationBar compact logo={<Lockup />} logoLabel="FairGarden home" action={action}>
        <Items />
      </NavigationBar>
    </div>
  )
}

API Reference

The site header: a skip link first, the green brand strip, an optional utility row, then the bar holding the logo (a home link), the Navigation Menu (from --fgd-nav-inline-n-above), icon Buttons, the one action and, below the threshold, the drawer’s menu Button. It is opaque, ruled at the bottom in --role-rule, 56 px tall (64 px from --lg-n-above), and its items never wrap: overflow goes to the utility row, then a “More” item [D183]. It prints as the §7.8 masthead’s logo only.

PropTypeDescription
action
React.ReactNode | undefined

The one primary action: a solid Button at size="sm". Below --md-n-above (768 px) it moves to the drawer footer, so repeat it there.

brandDrawing
React.ReactNode | undefined

An optional fine-line brand drawing (--border-size-0–75) beside the logo; dropped when compact.

compact
boolean | null | undefined

true: the compact header, even undocked. The sticky observer sets it while docked. Default false.

currentPath
string | undefined

The current page’s URL path, shared with the menu, drawer and utility links.

dock
NavigationBarDock | undefined

How the header docks. Default none.

drawer
React.ReactNode | undefined

The NavDrawer (menu Button and sheet), shown below --fgd-nav-inline-n-above.

logo
React.ReactNode | undefined

The logo: an ink logo in currentColor (an svg or img), 28 px tall, 36 px from --lg-n-above. On a narrow bar it gives way (clipped in its 44 px target); a lockup drops its wordmark.

logoHref
string | undefined

The home link. Default “/".

logoLabel
string | undefined

The home link’s accessible name, e.g. “FairGarden home”.

masthead
boolean | null | undefined

true: the stacked masthead. Default false.

onDockChange
((docked: boolean) => void) | undefined

Called when the header docks (true) or returns to its place (false).

preset
BandPreset | undefined

The header preset: a page ground (paper, white or the page’s pastel), or night only directly over the night media hero. Omitted, the header takes the page ground it sits in.

primary
| 'ruby'
| 'olive'
| 'sage'
| 'slate'
| 'sand'
| 'gray'
| 'mauve'
| 'brown'
| 'bronze'
| 'gold'
| 'red'
| 'crimson'
| 'tomato'
| 'pink'
| 'plum'
| 'indigo'
| 'iris'
| 'violet'
| 'purple'
| null
| undefined

Override the preset’s primary (a pairing §2 verifies). Never defaulted [D133].

renderLink
((href: string) => ReactElement) | undefined

Builds the home link, e.g. (href) => <NextLink href={href} />; the drawer’s bar repeats it. Default: a plain <a href>.

ruled
boolean | null | undefined

true: vertical --border-size-1 rules between items. Default false.

search
React.ReactNode | undefined

Icon Buttons, e.g. <Search kind="trigger" … />, --size-px-1 apart.

secondary
| 'ruby'
| 'olive'
| 'sage'
| 'slate'
| 'sand'
| 'gray'
| 'mauve'
| 'brown'
| 'bronze'
| 'gold'
| 'red'
| 'crimson'
| 'tomato'
| 'pink'
| 'plum'
| 'indigo'
| 'iris'
| 'violet'
| 'purple'
| 'amber'
| 'blue'
| 'cyan'
| 'grass'
| 'green'
| 'jade'
| 'lime'
| 'mint'
| 'orange'
| 'sky'
| 'teal'
| 'yellow'
| null
| undefined

Override the preset’s secondary. Never defaulted.

sentinelRef
React.RefObject<Element | null> | undefined

With dock="swap": a zero-height element at the section bar’s in-flow position.

skipHref
string | undefined

The skip link’s target. Default “#main”. Inside the docs layout, which renders the page’s skip link itself, the bar renders none.

skipLabel
string | undefined

The skip link’s words. Default “Skip to main content”.

utility
React.ReactNode | undefined

A NavigationBarUtility row above the bar, from --fgd-nav-inline-n-above; never docks.

wide
boolean | null | undefined

true: the bar’s content box, and the utility row’s, run to --fgd-container-wide rather than --fgd-container-content, aligned with a wide page frame: the docs layout’s columns [D202]. Default false.

children
React.ReactNode | undefined

The NavigationMenu, inline from --fgd-nav-inline-n-above.

The 36 px utility row above the bar (§11.3): secondary destinations as text links in a nav labelled “Utility”, divided from the bar by a --role-hairline rule, aligned to --fgd-container-content. Shown from --fgd-nav-inline-n-above (below it, repeat its links in the drawer footer); the compact docked header drops it [D183]. Put it in the bar’s utility slot.

PropTypeDescription
label
string | undefined

The landmark’s name. Default “Utility”.

locale
React.ReactNode | undefined

An optional locale link at the end (“English ▾ Change language”); a control never sits here.

start
React.ReactNode | undefined

An optional start slot: a phone number or tagline, in --primary12.

children
React.ReactNode | undefined

The row’s NavigationBarUtilityLinks: text links only.

A utility link: type-label caps, no rest underline, the bare-text underline on hover [D181], a 24 px target at a 24 px pitch (the §1.5.12 utility exemption). The current page (its path equals the bar’s currentPath) takes aria-current="page" and the --border-size-2–25 bar.

Additional types

navigationBar
NavigationBarContext
NavigationBarContextValue
NavigationBarDock
NavigationBarProps
NavigationBarUtilityLinkProps
NavigationBarUtilityProps

Specification: DESIGN-SYSTEM.md §11.5 (navigation bar) [D182, D183] and §11.3 (brand strip and utility bar); print per §7.8 (the masthead).