Skip to content

Navigation

Website headers that are hard to get right by hand: mega menus that morph between panels, a floating bar that follows the page, a fullscreen menu with levels, a docs header, a shop's header, and the sitemap footer.

Installation & usage

npx @youj/cli add marketing-navbar

Also installs accordion, app-header, avatar, badge, button, collapse, command, command-palette, dropdown-menu, icon-arrow-right, icon-bar-chart, icon-book-open, icon-briefcase, icon-building, icon-code, icon-credit-card, icon-database, icon-git-branch, icon-globe, icon-history, icon-layout-dashboard, icon-life-buoy, icon-log-out, icon-megaphone, icon-rocket, icon-search, icon-settings, icon-shield-check, icon-shopping-bag, icon-sparkles, icon-terminal, icon-users, icon-x, mega-menu, navigation-menu, sparkline, youj-core, youj-ui-core.

The CLI copies the block to blocks/marketing/navbar.tsx with every component it uses, so it’s yours to edit.

Every prop is optional and falls back to the demo, so it renders as you see it until you pass your own. Give it your data, rewrite or translate its strings through copy, and connect its actions:

marketingNavbar-view.tsx
'use client'

import Link from 'next/link'
import { MarketingNavbar, type MarketingNavbarProps } from '@/blocks/marketing/navbar'

export function MarketingNavbarView({ links, brand, accountLinks, searchItems }: Pick<MarketingNavbarProps, 'links' | 'brand' | 'accountLinks' | 'searchItems'>) {
  return (
    <MarketingNavbar
      links={links}
      brand={brand}
      accountLinks={accountLinks}
      searchItems={searchItems}
      copy={{ navLabel: 'Main' }}
      linkComponent={Link}
      onMenuChange={(menu) => {
        // your code
      }}
      onDismissAnnouncement={() => {
        // your code
      }}
      onSignOut={() => {
        // your code
      }}
    />
  )
}

Building an app rather than a site? Its navigation and the rest of its chrome are built in Create: a sidebar, a top bar with breadcrumbs, search or tabs, the workspace switcher, notifications and the account menu, with the screens you add as the pages of its nav.

Reference

Props22 props, 11 types

Props

MarketingNavbar props
PropType
currentstring

The link of the page being shown, marked as current; the trigger of the menu holding it carries a dot.

–
menustring | null

The open mega menu's label, null for none, to control it (close it on a route change, say).

–
defaultMenustring | null

The mega menu open at first, when uncontrolled. Default: none.

–
onMenuChange(menu: string | null) => void

Called with the label of the menu that opens, or null as it closes.

–
stickyboolean

Stick to the top and condense on scroll.

default true

true
scrollContainerRefObject<HTMLElement | null>

The element that scrolls under the bar. Default: the page.

–
linksMarketingNavbarItem[]

The top-level entries, in order: plain links and mega menus.

default the demo's Product, Solutions, Resources, Customers and Pricing

the demo's Product, Solutions, Resources, Customers and Pricing
brandMarketingNavbarBrand

The product's name, logo and home link.

default the demo's Northwind

the demo's Northwind
announcementMarketingNavbarAnnouncement | null

The bar above the header; null hides it.

default the demo's launch notice

the demo's launch notice
onDismissAnnouncement() => void

The announcement was dismissed (the visitor's choice to remember is yours).

–
userMarketingNavbarUser | null

The signed-in person: the bar shows the dashboard button and the account menu instead of the sign-in calls to action.

default null

null
accountLinksMarketingNavbarAccountLink[]

The account menu's pages above Sign out.

default Dashboard, Billing and Settings

Dashboard, Billing and Settings
onSignOut() => void

Called when the visitor chooses Sign out.

–
dashboardCtaMarketingNavbarCta | null

The signed-in button on the bar; null hides it.

default Dashboard → `#dashboard`

Dashboard → `#dashboard`
primaryCtaMarketingNavbarCta | null

The solid call to action when signed out, on the bar from md and first in the drawer; null hides it.

default Start free → `#signup`

Start free → `#signup`
secondaryCtaMarketingNavbarCta | null

The quiet call to action beside it; null hides it.

default Sign in → `#login`

Sign in → `#login`
searchboolean

Show the ⌘K search.

default true

true
searchItemsMarketingNavbarSearchItem[]

Pages the search finds beyond the menus' links.

default Pricing, Customers, Security and Contact

Pricing, Customers, Security and Contact
onSearchSelect(item: MarketingNavbarSearchItem) => void

Called when a search result is chosen. Default: go to its href.

–
actionsReactNode

Extra controls on the inline end, before the search (a theme toggle, a GitHub star count).

–
linkComponentLinkComponent

The element every internal link renders as, e.g. Next.js Link.

default 'a'

'a'
copyPartial<MarketingNavbarCopy>

Any of the block's strings, to rewrite or translate.

–

MarketingNavbarItem

MarketingNavbarItem props
PropType
labelRequiredstring–
hrefstring

A plain link's target.

–
groupsMarketingNavbarGroup[]

A mega menu's columns.

–
featured{ href: string; title: string; eyebrow?: string; description?: string }

A strip under the mega menu's columns: a launch, a case study, "See everything".

–
cardsMarketingNavbarCard[]

Media cards in the menu's last column, in place of the preview.

–
iconReactNode

A plain link's glyph in the drawer.

–
badgestring

A plain link's tag in the drawer.

–

MarketingNavbarGroup

MarketingNavbarGroup props
PropType
titleRequiredstring–
linksRequiredMarketingNavbarLink[]–
MarketingNavbarLink props
PropType
labelRequiredstring–
hrefRequiredstring–
iconReactNode

A 16px glyph.

–
descriptionstring

One line under the label.

–
badgestring

A small tag after the label ("New", "Beta").

–
previewMarketingNavbarPreview

What the menu's preview card shows while this link is hovered or focused.

–

MarketingNavbarCard

MarketingNavbarCard props
PropType
hrefRequiredstring–
titleRequiredstring–
eyebrowstring

A small line above the title ("Blog").

–
metastring

A line under the title ("6 min read").

–
mediaReactNode

The card's picture. Decorative. Default: a tinted wash.

–

MarketingNavbarPreview

MarketingNavbarPreview props
PropType
mediaReactNode

A picture of the thing; default a tinted wash.

–
titlestring

Default: the link's label.

–
descriptionstring

Default: the link's description.

–

MarketingNavbarCta

MarketingNavbarCta props
PropType
labelRequiredstring–
hrefRequiredstring–
onClickMouseEventHandler<HTMLAnchorElement>–

MarketingNavbarBrand

MarketingNavbarBrand props
PropType
nameRequiredstring–
logoReactNode–
hrefstring–

MarketingNavbarAnnouncement

MarketingNavbarAnnouncement props
PropType
labelRequiredstring

The message: "Northwind 2.0 is here".

–
hrefRequiredstring–
badgestring

A pill before the message ("New").

–
ctastring

The link's own words after the message ("Read the launch post").

–

MarketingNavbarUser

MarketingNavbarUser props
PropType
nameRequiredstring–
emailstring–
avatarstring

A photo's URL; initials otherwise.

–
MarketingNavbarAccountLink props
PropType
labelRequiredstring–
hrefRequiredstring–
iconReactNode–

MarketingNavbarSearchItem

MarketingNavbarSearchItem props
PropType
idRequiredstring–
labelRequiredstring–
hrefRequiredstring–
groupstring

The palette group it sits under.

–
keywordsstring[]

More words it's found by.

–
Strings14 keys for copy

Strings

copy takes any of these keys; the rest keep their defaults. A key whose text holds a value (a count, a name) takes a function.

navLabelmenusearchLabelsearchPlaceholdersearchTitlesearchPagessignInsignUpdashboardsignOutaccountdismissAnnouncementannouncementLabelsections
Built from12 components
Accessibilitylandmarks, menus, focus, keyboard, motion

Accessibility

Every header is a <header> landmark holding a labelled nav, and the page being shown is marked with aria-current="page"; the Floating bar marks the section in view with aria-current="true". Each starts with a skip link to your content (skipTo, #content by default), hidden until it takes keyboard focus. Links and buttons are real a and button elements with the kit's focus ring.

The Mega menu and the Store's departments are built on the kit's navigation menu, and the version and region menus on its menu: Enter, Space or ↓ opens one, Tab moves through a panel's links and the arrow keys through a menu's items, and Escape closes it and returns focus to its trigger. The previews and pictures beside the links are decorative, so the link's own words carry the meaning. ⌘K or Ctrl+K opens the Mega menu's and the Docs search from anywhere; the search palettes are dialogs whose results are a listbox you move through with the arrow keys.

The Fullscreen menu is a modal dialog named Menu. Opened from the keyboard, focus lands on its first entry; a level that drills in is a group named after its parent, focus moves to its first entry, and Back returns focus to the entry it came from. Escape closes it from any level and focus returns to Menu. The phone drawers of the Mega menu, Docs and Store are modal sheets that trap focus and return it to their button. The Floating bar's phone menu is a disclosure: its button carries aria-expanded, Escape or a press outside folds it, and focus goes back to the button.

The Floating bar hides as you scroll down, never while focus or its menu is inside it, and never under reduced motion. With reduced motion every header keeps its states (condensed, current, open) and shows them at once: nothing glides, rises or slides.

Footer is a <footer> landmark with a labelled nav whose link groups sit under h2 headings. The newsletter field has a label, and the result of signing up is announced in a status region. The language switch and trust badges are labelled.