Skip to main content

Navbar Pro

Navbar is the top bar of a landing page or a web app's public site, built the way Vercel, Linear and Stripe build theirs. On wide screens: the logo, links, and mega menus (columns of links with icons and a line each, a featured card, a footer strip) that open on hover, focus or press, with an indicator that slides under the pointer and a panel that glides and resizes from one menu to the next. It sticks to the top and turns frosted with a hairline once the page scrolls. Under 768 points it becomes the logo, your main button and a menu button that opens a full-screen menu whose rows rise in one after another, with menus as accordions and the buttons pinned at the bottom.

import { Navbar, useNavbarScroll } from '@patine-ui/pro';
Loading…
<View style={{ height: 420, width: '100%' }}>
  <Navbar
    brand={{ name: 'Signal', mark: 'S', color: '#18181B' }}
    items={[
      { key: 'product', label: 'Product', menu: product },
      { key: 'solutions', label: 'Solutions', menu: solutions },
      { key: 'docs', label: 'Docs', onPress: () => {} },
      { key: 'pricing', label: 'Pricing', onPress: () => {} },
    ]}
    active="pricing"
    secondaryCta={{ label: 'Sign in' }}
    cta={{ label: 'Start for free' }}
    sticky={false}
    scrolled
  />
</View>

Example: a developer docs site​

A docs site's navbar: plain links that track the current section, a search button in actions, and one call to action. Narrow the window to see it fold into the menu button.

Loading…
<View style={{ height: 220, width: '100%' }}>
  <Navbar
    brand={{ name: 'Relay', mark: 'R', color: '#0F766E' }}
    items={SECTIONS.map((s) => ({ ...s, onPress: () => setActive(s.key) }))}
    active={active}
    actions={
      <Button size="icon" variant="ghost" accessibilityLabel="Search the docs">
        <Icon name="search" />
      </Button>
    }
    secondaryCta={{ label: 'Dashboard' }}
    cta={{ label: 'Get an API key' }}
    sticky={false}
  />
  <Text style={{ padding: 24 }} color="textSecondary">
    {SECTIONS.find((s) => s.key === active)?.label}
  </Text>
</View>

Mega menus​

Give an item a menu: columns of links (each { label, description?, icon?, badge?, onPress? }, under an optional title), a featured card for a launch or a case study (color fills it; text turns white), and a footer strip for Changelog, Status or Contact sales. Menus open after a short hover so a pointer passing over doesn't flash one; once one is open, moving along the bar switches at once, and there's a grace before closing so the pointer can travel down to the panel. A click or Enter toggles it, which is what a touch screen does.

Sticky, frosted on scroll​

On the web the bar sticks to the top of the page and watches the window: once it scrolls, the bar turns translucent with a blur behind it and a hairline under it. When your page scrolls in a ScrollView of its own, as in an Expo app, pass scrolled yourself; useNavbarScroll() gives you both halves.

const scroll = useNavbarScroll();

<View style={{ flex: 1 }}>
<Navbar {...nav} scrolled={scroll.scrolled} style={{ position: 'absolute', top: 0, left: 0, right: 0 }} />
<ScrollView {...scroll} contentContainerStyle={{ paddingTop: 64 }}>{page}</ScrollView>
</View>

On phones​

Under 768 points the links fold into a menu button whose lines turn into an ✕. The menu covers the screen: each item rises in a beat after the one above, items with a menu open as accordions with every link and its description, and your buttons sit at the bottom within thumb reach. Back on Android and Escape on the web close it.

Press the menu button:

Loading…
<View style={{ flex: 1 }}>
  <Navbar
    brand={{ name: 'Signal', mark: 'S', color: '#18181B' }}
    items={[
      { key: 'product', label: 'Product', menu: product },
      { key: 'docs', label: 'Docs', onPress: () => {} },
      { key: 'pricing', label: 'Pricing', onPress: () => {} },
    ]}
    secondaryCta={{ label: 'Sign in' }}
    cta={{ label: 'Start for free' }}
    sticky={false}
  />
</View>

Accessibility​

  • The bar is a banner landmark; the links are a menu bar. An item with a menu is a button that says whether it's expanded and that it opens a menu; the current page's item is aria-current="page".
  • ↓ on an item opens its menu and moves into it; Escape closes it and puts focus back on the item; Tab moves through the links.
  • The phone menu is a modal dialog named Menu; accordions say whether they're open. Every target is at least 44 points.
  • Hover isn't needed for anything: a press opens every menu. Motion follows reduce motion.

Props​

PropTypeDefault
brand{ name, mark?, color? }
logoReactNode, your own logo instead of the brand's tile and name
onLogoPress() => void
items{ key, label, onPress?, menu? }[]
activestring, the current page's key
cta, secondaryCta{ label, onPress? }
actionsReactNode, before the buttons, such as a theme switch
scrolledboolean: frosted with a hairlineThe window's scroll, on the web
stickyboolean, sticks to the top on the webtrue
maxWidthnumber, the content's widest1200