Skip to content

Navbar

A site navigation bar that is invisible at rest, with the logo dead centre, and folds into a floating blurred capsule once the page scrolls under it; a nine-dot button opens a menu drawer.

Preview

Theme

Care that comes to you

Book a visit, pay at the pharmacy and claim lab tests from one app, with cashless care at partner clinics.

Plans

Scroll on: the bar folds into a capsule once this page has moved under it, and unfolds on the way back up.

Clinics

Scroll on: the bar folds into a capsule once this page has moved under it, and unfolds on the way back up.

Stories

Scroll on: the bar folds into a capsule once this page has moved under it, and unfolds on the way back up.

Installation

pnpm add @syntara/react @syntara/tokens
import { Navbar, NavbarLogo, NavbarLink, NavbarAction, NavbarMenuGroup, NavbarMenuLink } from '@syntara/react';

Usage

import { Navbar, NavbarAction, NavbarLink, NavbarLogo, NavbarMenuGroup, NavbarMenuLink } from '@syntara/react';

export function SiteNav() {
  return (
    <Navbar
      logo={<NavbarLogo href="/">Acme</NavbarLogo>}
      actions={
        <>
          <NavbarLink href="/login">Log in</NavbarLink>
          <NavbarAction href="/join">Join now</NavbarAction>
        </>
      }
      menu={
        <NavbarMenuGroup title="Explore">
          <NavbarMenuLink href="/plans">Plans</NavbarMenuLink>
          <NavbarMenuLink href="/clinics">Clinics</NavbarMenuLink>
        </NavbarMenuGroup>
      }
    >
      <NavbarLink href="/plans" isCurrent>Plans</NavbarLink>
      <NavbarLink href="/clinics">Clinics</NavbarLink>
    </Navbar>
  );
}

Examples

Folded

The capsule, pinned with isScrolled: the brand's inverse colour over blurred page, the logo at three quarters, the pill inverted, the dots in their own circle.

Theme

Scroll on: the bar folds into a capsule once this page has moved under it, and unfolds on the way back up. Book a visit, pay at the pharmacy and claim lab tests from one app, with cashless care at partner clinics. Scroll on: the bar folds into a capsule once this page has moved under it, and unfolds on the way back up.

No actions and no menu: just the brand and the links, still folding on scroll.

Theme

Plans

Scroll on: the bar folds into a capsule once this page has moved under it, and unfolds on the way back up.

Clinics

Scroll on: the bar folds into a capsule once this page has moved under it, and unfolds on the way back up.

Stories

Scroll on: the bar folds into a capsule once this page has moved under it, and unfolds on the way back up.

Accessibility

KeysAction
TabMoves through the logo, the links, the actions and the menu button, in reading order.
EnterorSpaceOn the menu button, opens the drawer and moves focus into it.
EscapeCloses the drawer and returns focus to the menu button.
  • A header landmark holding one navigation landmark named by navLabel; the logo link names the brand.
  • The nine-dot button is a real button named by menuLabel, with aria-expanded; the drawer is a dialog with the same name (React Aria DialogTrigger + Sheet).
  • Hovering a link quietens its neighbours to text.subtle, a colour the engine proves at 4.5:1, never to an opacity. Inside the folded capsule they quieten to a mix that test/navbar.test.tsx proves ≥ 4.5:1 on every tenant and 1,000 fuzz brands, light and dark.
  • The folded capsule is surface.inverse at the glass opacity plus 8 points, with text.inverse on it: the same test proves ≥ 4.5:1 over black and white backdrops.
  • Every target is at least 24px tall; every part shows the focus ring.
  • With reduced motion the capsule switches without moving, the hover dash stays put and only colours fade.

Guidelines

Do

  • Put it first inside the scroller: the page, or the frame it sits in. It takes no room, so start the page's first section with enough top padding to clear it.
  • Keep the start links to three or four short words, so they clear the centred logo: the bar lays out wide from 640px of its own width, and at that width three fit.
  • Repeat every link in the menu: narrow bars hide the start group.

Don’t

  • Don't put more than one NavbarAction in actions.
  • Don't give it a background of its own at rest; the bar is meant to be invisible until the page scrolls.
  • Don't nest it inside a container with overflow hidden and no scroll: it would never fold.

API reference

Navbar

logo
ReactNode

The brand, centred on wide bars and at the start on narrow ones: a NavbarLogo, or any link with the logo in it.

actions
ReactNode

The end group: a quiet NavbarLink such as "Log in" and one NavbarAction pill. Narrow bars hide the link and keep the pill; the drawer shows both again at its top.

menu
ReactNode

The drawer's content, NavbarMenuGroups of links. When set, a nine-dot button at the end of the bar opens a Sheet from the end edge.

menuLabel
string

Names the nine-dot button and titles the drawer.

Default 'Menu'

navLabel
string

Names the navigation landmark for screen readers.

Default 'Main'

isScrolled
boolean

Pins the folded state. Leave it out and the bar folds itself once the page (or the frame it sits in) has scrolled 64px, and unfolds on the way back.

children
ReactNode

NavbarLinks for the start group. Narrow bars hide them, so repeat them in the menu.

childrenRequired
ReactNode

The brand: a wordmark as text, set in the heading font, or an image or SVG with an aria-label on the link.

isCurrent
boolean

Marks the link to the current page (aria-current="page"); it reads a step heavier.

NavbarAction

href
string

Where the pill goes. A React Aria Link, so it works with client routers; pass onPress instead for an action.

NavbarMenuGroup

titleRequired
ReactNode

The group's label, e.g. "Explore". Names its list for screen readers.

size
  • lgdefault
  • sm

lg: the drawer's big links in the heading font. sm: a column of small body-text links.

isCurrent
boolean

Marks the link to the current page (aria-current="page").

Tokens

The semantic tokens this component reads, grouped by what they control. Swatches show this site’s theme; change a tenant’s brand and the component follows with no code change.

Colour7
surface.inversesurface.defaulttext.defaulttext.subtletext.inverseborder.subtlefocus.ring
Type4
font.headingfont.size.smfont.size.lgfont.size.2xl
Space and size10
space.1space.2space.4space.5space.6space.8space.12space.16control.heightcontrol.padding-inline
Shape2
radius.pillradius.button
Depth4
glass.bgglass.blurglass.opacityshadow.raised
Motion4
motion.duration.fastmotion.duration.normalmotion.easing-outmotion.spring