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-navbarAlso 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:
'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
}}
/>
)
}Description
Mega menus on one popup that morphs from panel to panel: a preview card that follows the link you point at, media cards for posts and guides, a strip for a launch. With search, an announcement bar, signed-in and signed-out states, and a drawer of folding sections on phones. Pick it for a product with many parts.
A floating island over the page that draws in around its links once you scroll, follows the section in view with a gliding pill and a progress line, steps aside as you read on and returns when you scroll back. On phones the island grows into its own menu. Pick it for a focused product or a one-page site.
A documentation header in two rows: the version menu, a ⌘K search over every page that remembers what you opened, the repository with its stars, and the sections as tabs with a gliding underline. On phones a drawer holds the section's page tree, open to the current page. Pick it for docs, guides and API references.
A slim bar whose Menu opens the whole screen: large entries that rise into place, levels that drill in and back with focus kept in step, and a picture that follows the entry you point at. Pick it for a studio, an editorial product or any site that leads with its brand.
A shop's header: a strip with the delivery promise and the region and currency, departments with category columns and collection tiles, a search that suggests products priced in the shopper's currency, and a bag whose count drops in. Pick it for a storefront.
A sitemap: grouped links with tags, a newsletter sign-up, trust badges, legal links, a language switch and a live status pill.
Code
Navbar, the Mega menu story: the files youj add writes.
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
| Prop | Type | |
|---|---|---|
current | stringThe link of the page being shown, marked as current; the trigger of the menu holding it carries a dot. | – |
menu | string | nullThe open mega menu's label, | – |
defaultMenu | string | nullThe mega menu open at first, when uncontrolled. Default: none. | – |
onMenuChange | (menu: string | null) => voidCalled with the label of the menu that opens, or | – |
sticky | booleanStick to the top and condense on scroll. default true | true |
scrollContainer | RefObject<HTMLElement | null>The element that scrolls under the bar. Default: the page. | – |
links | MarketingNavbarItem[]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 |
brand | MarketingNavbarBrandThe product's name, logo and home link. default the demo's Northwind | the demo's Northwind |
announcement | MarketingNavbarAnnouncement | nullThe bar above the header; default the demo's launch notice | the demo's launch notice |
onDismissAnnouncement | () => voidThe announcement was dismissed (the visitor's choice to remember is yours). | – |
user | MarketingNavbarUser | nullThe signed-in person: the bar shows the dashboard button and the account menu instead of the sign-in calls to action. default null | null |
accountLinks | MarketingNavbarAccountLink[]The account menu's pages above Sign out. default Dashboard, Billing and Settings | Dashboard, Billing and Settings |
onSignOut | () => voidCalled when the visitor chooses Sign out. | – |
dashboardCta | MarketingNavbarCta | nullThe signed-in button on the bar; default Dashboard → `#dashboard` | Dashboard → `#dashboard` |
primaryCta | MarketingNavbarCta | nullThe solid call to action when signed out, on the bar from default Start free → `#signup` | Start free → `#signup` |
secondaryCta | MarketingNavbarCta | nullThe quiet call to action beside it; default Sign in → `#login` | Sign in → `#login` |
search | booleanShow the ⌘K search. default true | true |
searchItems | MarketingNavbarSearchItem[]Pages the search finds beyond the menus' links. default Pricing, Customers, Security and Contact | Pricing, Customers, Security and Contact |
onSearchSelect | (item: MarketingNavbarSearchItem) => voidCalled when a search result is chosen. Default: go to its | – |
actions | ReactNodeExtra controls on the inline end, before the search (a theme toggle, a GitHub star count). | – |
linkComponent | LinkComponentThe element every internal link renders as, e.g. Next.js default 'a' | 'a' |
copy | Partial<MarketingNavbarCopy>Any of the block's strings, to rewrite or translate. | – |
MarketingNavbarItem
| Prop | Type | |
|---|---|---|
labelRequired | string | – |
href | stringA plain link's target. | – |
groups | MarketingNavbarGroup[]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". | – |
cards | MarketingNavbarCard[]Media cards in the menu's last column, in place of the preview. | – |
icon | ReactNodeA plain link's glyph in the drawer. | – |
badge | stringA plain link's tag in the drawer. | – |
MarketingNavbarGroup
| Prop | Type | |
|---|---|---|
titleRequired | string | – |
linksRequired | MarketingNavbarLink[] | – |
MarketingNavbarLink
| Prop | Type | |
|---|---|---|
labelRequired | string | – |
hrefRequired | string | – |
icon | ReactNodeA 16px glyph. | – |
description | stringOne line under the label. | – |
badge | stringA small tag after the label ("New", "Beta"). | – |
preview | MarketingNavbarPreviewWhat the menu's preview card shows while this link is hovered or focused. | – |
MarketingNavbarCard
| Prop | Type | |
|---|---|---|
hrefRequired | string | – |
titleRequired | string | – |
eyebrow | stringA small line above the title ("Blog"). | – |
meta | stringA line under the title ("6 min read"). | – |
media | ReactNodeThe card's picture. Decorative. Default: a tinted wash. | – |
MarketingNavbarPreview
| Prop | Type | |
|---|---|---|
media | ReactNodeA picture of the thing; default a tinted wash. | – |
title | stringDefault: the link's label. | – |
description | stringDefault: the link's description. | – |
MarketingNavbarCta
| Prop | Type | |
|---|---|---|
labelRequired | string | – |
hrefRequired | string | – |
onClick | MouseEventHandler<HTMLAnchorElement> | – |
MarketingNavbarBrand
| Prop | Type | |
|---|---|---|
nameRequired | string | – |
logo | ReactNode | – |
href | string | – |
MarketingNavbarAnnouncement
| Prop | Type | |
|---|---|---|
labelRequired | stringThe message: "Northwind 2.0 is here". | – |
hrefRequired | string | – |
badge | stringA pill before the message ("New"). | – |
cta | stringThe link's own words after the message ("Read the launch post"). | – |
MarketingNavbarUser
| Prop | Type | |
|---|---|---|
nameRequired | string | – |
email | string | – |
avatar | stringA photo's URL; initials otherwise. | – |
MarketingNavbarAccountLink
| Prop | Type | |
|---|---|---|
labelRequired | string | – |
hrefRequired | string | – |
icon | ReactNode | – |
MarketingNavbarSearchItem
| Prop | Type | |
|---|---|---|
idRequired | string | – |
labelRequired | string | – |
hrefRequired | string | – |
group | stringThe palette group it sits under. | – |
keywords | string[]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.
navLabelmenusearchLabelsearchPlaceholdersearchTitlesearchPagessignInsignUpdashboardsignOutaccountdismissAnnouncementannouncementLabelsectionsBuilt 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.