Navbar
A site's header, in a header landmark: its brand linking home, a NavigationMenu of links and panels, and calls to action, folded into a sheet on phones.
import { Navbar, type NavbarItem } from "@produkto/ui/Navbar"; import { Hexagon01Icon } from "@hugeicons/core-free-icons"; import { Icon } from "@produkto/ui/Icon"; import type { BlockAction } from "@produkto/ui/Section"; const items: NavbarItem[] = [ { label: "Item 1", links: [ { label: "Link 1", link: "#", }, { label: "Link 2", link: "#", }, { label: "Link 3", link: "#", }, ], }, { label: "Item 2", links: [ { label: "Link 4", link: "#", }, { label: "Link 5", link: "#", }, ], }, { label: "Item 3", link: "#" }, ]; const actions: BlockAction[] = [ { label: "Secondary action", link: "#" }, { label: "Primary action", link: "#" }, ]; const Example = () => ( <div className="h-80"> <Navbar actions={actions} brand={ <span className="flex items-center gap-2"> <Icon icon={Hexagon01Icon} size={22} /> Brand </span> } items={items} /> </div> ); export default Example;
Usage
import { Navbar, type NavbarItem } from "@produkto/ui/Navbar"; import type { BlockAction } from "@produkto/ui/Section";
const items: NavbarItem[] = [ { label: "Item 1", link: "#" }, { label: "Item 2", link: "#" }, { label: "Item 3", link: "#" }, ]; const actions: BlockAction[] = [ { label: "Secondary action", link: "#" }, { label: "Primary action", link: "#" }, ]; <Navbar brand="Brand" items={items} actions={actions} />
Examples
Links only
items given a link each make a plain row of links, with no panels to open.
import { Navbar, type NavbarItem } from "@produkto/ui/Navbar"; import { Hexagon01Icon } from "@hugeicons/core-free-icons"; import { Icon } from "@produkto/ui/Icon"; import type { BlockAction } from "@produkto/ui/Section"; const items: NavbarItem[] = [ { label: "Item 1", link: "#" }, { label: "Item 2", link: "#" }, { label: "Item 3", link: "#" }, { label: "Item 4", link: "#" }, ]; const actions: BlockAction[] = [{ label: "Primary action", link: "#" }]; const Example = () => ( <Navbar actions={actions} brand={ <span className="flex items-center gap-2"> <Icon icon={Hexagon01Icon} size={22} /> Brand </span> } items={items} /> ); export default Example;
With a dropdown
The first item opens a short list, each link with a line under it.
import { Navbar, type NavbarItem } from "@produkto/ui/Navbar"; import type { BlockAction } from "@produkto/ui/Section"; const items: NavbarItem[] = [ { label: "Item 1", columns: 1, links: [ { label: "Link 1", link: "#", description: "A short line about it." }, { label: "Link 2", link: "#", description: "A short line about it." }, { label: "Link 3", link: "#", description: "A short line about it." }, ], }, { label: "Item 2", link: "#" }, { label: "Item 3", link: "#" }, { label: "Item 4", link: "#" }, ]; const actions: BlockAction[] = [{ label: "Primary action", link: "#" }]; const Example = () => ( <div className="h-96"> <Navbar actions={actions} brand="Brand" items={items} /> </div> ); export default Example;
Wide panel
The first item opens a wide panel of the catalogue's groups, each under its label, with a featured link at its foot.
import { Navbar, type NavbarItem } from "@produkto/ui/Navbar"; import type { BlockAction } from "@produkto/ui/Section"; const items: NavbarItem[] = [ { label: "Item 1", groups: [ { label: "Group 1", links: [ { label: "Link 1", link: "#" }, { label: "Link 2", link: "#" }, { label: "Link 3", link: "#" }, ], }, { label: "Group 2", links: [ { label: "Link 4", link: "#" }, { label: "Link 5", link: "#" }, { label: "Link 6", link: "#" }, ], }, { label: "Group 3", links: [ { label: "Link 7", link: "#" }, { label: "Link 8", link: "#" }, { label: "Link 9", link: "#" }, ], }, ], footer: { label: "Featured link", link: "#", description: "A short line about the featured item.", }, }, { label: "Item 2", link: "#" }, { label: "Item 3", link: "#" }, ]; const actions: BlockAction[] = [{ label: "Primary action", link: "#" }]; const Example = () => ( <div className="h-[28rem]"> <Navbar actions={actions} brand="Brand" items={items} /> </div> ); export default Example;
Controls
Its children sit at the end of the bar, ahead of its icon links and actions, at every width: here a DropdownMenu behind an icon Button with a Tooltip.
import { Button } from "@produkto/ui/Button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@produkto/ui/DropdownMenu"; import { Navbar, type NavbarItem } from "@produkto/ui/Navbar"; import { Tooltip, TooltipContent, TooltipTrigger, } from "@produkto/ui/Tooltip"; import { Globe02Icon, Hexagon01Icon } from "@hugeicons/core-free-icons"; import { Icon } from "@produkto/ui/Icon"; import type { BlockAction } from "@produkto/ui/Section"; const items: NavbarItem[] = [ { label: "Item 1", link: "#" }, { label: "Item 2", link: "#" }, { label: "Item 3", link: "#" }, ]; const actions: BlockAction[] = [{ label: "Button", link: "#" }]; const entries: string[] = ["Item 1", "Item 2", "Item 3"]; const Example = () => ( <Navbar actions={actions} align="center" brand={ <span className="flex items-center gap-2"> <Icon icon={Hexagon01Icon} size={22} /> Brand </span> } items={items} > <DropdownMenu> <Tooltip> <TooltipTrigger asChild> <DropdownMenuTrigger asChild> <Button aria-label="Language" appearance="transparent" size="sm"> <Icon icon={Globe02Icon} /> </Button> </DropdownMenuTrigger> </TooltipTrigger> <TooltipContent>Language</TooltipContent> </Tooltip> <DropdownMenuContent align="end"> {entries.map((entry) => ( <DropdownMenuItem key={entry}>{entry}</DropdownMenuItem> ))} </DropdownMenuContent> </DropdownMenu> </Navbar> ); export default Example;
Links centred
align="center" sets the links in the middle of the bar, between the brand and the actions.
import { Navbar, type NavbarItem } from "@produkto/ui/Navbar"; import { Hexagon01Icon } from "@hugeicons/core-free-icons"; import { Icon } from "@produkto/ui/Icon"; import type { BlockAction } from "@produkto/ui/Section"; const items: NavbarItem[] = [ { label: "Item 1", links: [ { label: "Link 1", link: "#", }, { label: "Link 2", link: "#", }, { label: "Link 3", link: "#", }, ], }, { label: "Item 2", link: "#" }, { label: "Item 3", link: "#" }, ]; const actions: BlockAction[] = [ { label: "Secondary action", link: "#" }, { label: "Primary action", link: "#" }, ]; const Example = () => ( <div className="h-80"> <Navbar actions={actions} align="center" brand={ <span className="flex items-center gap-2"> <Icon icon={Hexagon01Icon} size={22} /> Brand </span> } items={items} /> </div> ); export default Example;
Links right
align="end" gathers the links beside the actions at the end of the bar, for a short name.
import { Navbar, type NavbarItem } from "@produkto/ui/Navbar"; import { Hexagon01Icon } from "@hugeicons/core-free-icons"; import { Icon } from "@produkto/ui/Icon"; import type { BlockAction } from "@produkto/ui/Section"; const items: NavbarItem[] = [ { label: "Item 1", link: "#" }, { label: "Item 2", link: "#" }, { label: "Item 3", link: "#" }, { label: "Item 4", link: "#" }, ]; const actions: BlockAction[] = [{ label: "Primary action", link: "#" }]; const Example = () => ( <Navbar actions={actions} align="end" brand={ <span className="flex items-center gap-2"> <Icon icon={Hexagon01Icon} size={22} /> Brand </span> } items={items} /> ); export default Example;
Name centred
layout="split" sets the brand in the middle, the first half of the links before it and the rest after it, ahead of the actions.
import { Navbar, type NavbarItem } from "@produkto/ui/Navbar"; import type { BlockAction } from "@produkto/ui/Section"; const items: NavbarItem[] = [ { label: "Item 1", link: "#" }, { label: "Item 2", link: "#" }, { label: "Item 3", link: "#" }, { label: "Item 4", link: "#" }, ]; const actions: BlockAction[] = [{ label: "Primary action", link: "#" }]; const Example = () => ( <Navbar actions={actions} layout="split" brand="Brand" items={items} /> ); export default Example;
Floating
floating lifts the bar off the top edge as a rounded panel with a border and a shadow, inset from the sides.
import { Navbar, type NavbarItem } from "@produkto/ui/Navbar"; import { Hexagon01Icon } from "@hugeicons/core-free-icons"; import { Icon } from "@produkto/ui/Icon"; import type { BlockAction } from "@produkto/ui/Section"; const items: NavbarItem[] = [ { label: "Item 1", link: "#" }, { label: "Item 2", link: "#" }, { label: "Item 3", link: "#" }, { label: "Item 4", link: "#" }, ]; const actions: BlockAction[] = [{ label: "Primary action", link: "#" }]; const Example = () => ( <div className="w-full bg-muted pb-16"> <Navbar actions={actions} align="center" brand={ <span className="flex items-center gap-2"> <Icon icon={Hexagon01Icon} size={22} /> Brand </span> } floating items={items} /> </div> ); export default Example;
Over the opening
over lays the bar clear over the section under it and gives it its ground once the page scrolls past its top, here with theme="dark" over a dark opening. Scroll the frame.
import { Hero } from "@produkto/ui/Hero"; import { Navbar, type NavbarItem } from "@produkto/ui/Navbar"; import { ScrollArea } from "@produkto/ui/ScrollArea"; import type { BlockAction } from "@produkto/ui/Section"; const items: NavbarItem[] = [ { label: "Item 1", link: "#" }, { label: "Item 2", link: "#" }, { label: "Item 3", link: "#" }, { label: "Item 4", link: "#" }, ]; const actions: BlockAction[] = [{ label: "Primary action", link: "#" }]; const Example = () => ( <ScrollArea className="h-96 w-full"> <Navbar actions={actions} align="center" brand="Brand" items={items} over theme="dark" /> <div data-theme="dark"> <Hero actions={[{ label: "Primary action", link: "#" }]} description="A short line about what the product does goes here." eyebrow="Eyebrow" height="screen" title="Your headline goes here" /> </div> </ScrollArea> ); export default Example;
Columns
columns lays a long panel out in a grid of up to five, two across from md, three from lg and five from xl, where the panel is as wide as the bar's row; a panel taller than the window scrolls.
import { Navbar, type NavbarItem } from "@produkto/ui/Navbar"; import { Hexagon01Icon } from "@hugeicons/core-free-icons"; import { Icon } from "@produkto/ui/Icon"; const links = Array.from({ length: 15 }, (_, index) => ({ label: `Link ${index + 1}`, link: "#", })); const items: NavbarItem[] = [ { label: "Item 1", columns: 5, links }, { label: "Item 2", link: "#" }, ]; const Example = () => ( <div className="h-96"> <Navbar align="center" brand={ <span className="flex items-center gap-2"> <Icon icon={Hexagon01Icon} size={22} /> Brand </span> } items={items} /> </div> ); export default Example;
Columns down
rows sets how many links a column holds at most: the links run down each column in turn and the columns are balanced, twelve links in three columns of four.
import { Navbar, type NavbarItem } from "@produkto/ui/Navbar"; import { Hexagon01Icon } from "@hugeicons/core-free-icons"; import { Icon } from "@produkto/ui/Icon"; const items: NavbarItem[] = [ { label: "Item 1", rows: 5, links: Array.from({ length: 12 }, (_, at) => ({ label: `Link ${at + 1}`, description: "A line under the name", icon: <Icon icon={Hexagon01Icon} />, link: "#", })), }, { label: "Item 2", link: "#" }, ]; const Example = () => ( <div className="h-96"> <Navbar brand={ <span className="flex items-center gap-2"> <Icon icon={Hexagon01Icon} size={22} /> Brand </span> } items={items} /> </div> ); export default Example;
Icons
A panel link is a small transparent Button, its icon before its label, as it is in the sheet.
import { Navbar, type NavbarItem } from "@produkto/ui/Navbar"; import { Hexagon01Icon, Layers01Icon, Megaphone01Icon, ShoppingBag01Icon, } from "@hugeicons/core-free-icons"; import { Icon } from "@produkto/ui/Icon"; const items: NavbarItem[] = [ { label: "Item 1", links: [ { label: "Link 1", icon: <Icon icon={Layers01Icon} />, link: "#", }, { label: "Link 2", icon: <Icon icon={ShoppingBag01Icon} />, link: "#", }, { label: "Link 3", icon: <Icon icon={Megaphone01Icon} />, link: "#", }, ], }, { label: "Item 2", link: "#" }, ]; const Example = () => ( <div className="h-80"> <Navbar align="center" brand={ <span className="flex items-center gap-2"> <Icon icon={Hexagon01Icon} size={22} /> Brand </span> } items={items} /> </div> ); export default Example;
Menu action
An action given items opens a menu instead of following a link, in the bar and at the foot of the phone sheet: each item is a link or an onSelect. iconOnly draws it as its icon alone, its label the button's name.
import { Navbar, type NavbarItem, type NavbarProps, } from "@produkto/ui/Navbar"; import { Globe02Icon, Hexagon01Icon } from "@hugeicons/core-free-icons"; import { Icon } from "@produkto/ui/Icon"; const items: NavbarItem[] = [ { label: "Item 1", link: "#" }, { label: "Item 2", link: "#" }, ]; const actions: NavbarProps["actions"] = [ { label: "Language", icon: <Icon icon={Globe02Icon} />, appearance: "transparent", iconOnly: true, items: [ { label: "English", link: "?locale=en" }, { label: "Français", link: "?locale=fr" }, { label: "Deutsch", link: "?locale=de" }, ], }, { label: "Button", link: "#" }, ]; const Example = () => ( <div className="h-80"> <Navbar actions={actions} brand={ <span className="flex items-center gap-2"> <Icon icon={Hexagon01Icon} size={22} /> Brand </span> } items={items} /> </div> ); export default Example;
Muted with a border
muted lays the bar on the muted background, and bordered draws a rule under it.
import { Navbar, type NavbarItem } from "@produkto/ui/Navbar"; import { Hexagon01Icon } from "@hugeicons/core-free-icons"; import { Icon } from "@produkto/ui/Icon"; import type { BlockAction } from "@produkto/ui/Section"; const items: NavbarItem[] = [ { label: "Item 1", link: "#" }, { label: "Item 2", link: "#" }, { label: "Item 3", link: "#" }, ]; const actions: BlockAction[] = [ { label: "Secondary action", link: "#" }, { label: "Primary action", link: "#" }, ]; const Example = () => ( <Navbar actions={actions} bordered brand={ <span className="flex items-center gap-2"> <Icon icon={Hexagon01Icon} size={22} /> Brand </span> } items={items} muted /> ); export default Example;
Dark
theme="dark" draws the bar in the dark theme whatever the page wears, as over a dark hero, and its panels and menus open dark with it, the language menu here included.
import { Navbar, type NavbarItem, type NavbarProps, } from "@produkto/ui/Navbar"; import { Globe02Icon, Hexagon01Icon } from "@hugeicons/core-free-icons"; import { Icon } from "@produkto/ui/Icon"; const items: NavbarItem[] = [ { label: "Item 1", links: [ { label: "First link", link: "#" }, { label: "Second link", link: "#" }, ], }, { label: "Item 2", link: "#" }, ]; const actions: NavbarProps["actions"] = [ { label: "Language", icon: <Icon icon={Globe02Icon} />, appearance: "transparent", iconOnly: true, items: [ { label: "English", link: "?locale=en" }, { label: "Français", link: "?locale=fr" }, { label: "Deutsch", link: "?locale=de" }, ], }, { label: "Button", link: "#" }, ]; const Example = () => ( <div className="h-80"> <Navbar actions={actions} brand={ <span className="flex items-center gap-2"> <Icon icon={Hexagon01Icon} size={22} /> Brand </span> } items={items} theme="dark" /> </div> ); export default Example;
Mobile menu
Shown at the phone breakpoint, below md: a menu button opens a sheet with every link and the actions at the foot, each menu folded behind its label until it is tapped.
import { Navbar, type NavbarItem } from "@produkto/ui/Navbar"; import { Hexagon01Icon } from "@hugeicons/core-free-icons"; import { Icon } from "@produkto/ui/Icon"; import type { BlockAction } from "@produkto/ui/Section"; const items: NavbarItem[] = [ { label: "Item 1", links: [ { label: "Link 1", link: "#", }, { label: "Link 2", link: "#", }, { label: "Link 3", link: "#", }, ], }, { label: "Item 2", links: [ { label: "Link 4", link: "#", }, { label: "Link 5", link: "#", }, ], }, { label: "Item 3", link: "#" }, ]; const actions: BlockAction[] = [ { label: "Secondary action", link: "#" }, { label: "Primary action", link: "#" }, ]; const Example = () => ( <div className="h-80"> <Navbar actions={actions} brand={ <span className="flex items-center gap-2"> <Icon icon={Hexagon01Icon} size={22} /> Brand </span> } items={items} /> </div> ); export default Example;
API Reference
Navbar
NavbarProps · blocks/Navbar/Navbar.types.ts| Prop | Type | Default |
|---|---|---|
| id | string | - |
| brand | ReactNode | - |
| brandLink | string | "#" |
| items | NavbarItem[] | - |
| actions | (BlockAction | BlockMenuAction)[] | - |
| social | BlockSocialLink[] | - |
| align | NavbarAlign"start" | "center" | "end" | "start" |
| layout | NavbarLayout"row" | "split" | "row" |
| width | NavbarWidth"narrow" | "base" | "wide" | "full" | "base" |
| sticky | boolean | false |
| floating | boolean | false |
| over | boolean | false |
| muted | boolean | false |
| bordered | boolean | false |
| theme | ThemeMode"light" | "dark" | - |
| className | string | - |
| children | ReactNode | - |
NavbarItem
used by items| Prop | Type | Default |
|---|---|---|
| icon | ReactNode | - |
| description | string | - |
| active | boolean | - |
| label | string | - |
| link | string | - |
| links | NavbarLink[] | - |
| columns | NavbarColumns1 | 2 | 3 | 4 | 5 | - |
| rows | NavbarRows2 | 3 | 4 | 5 | 6 | - |
| groups | NavbarGroup[] | - |
| footer | NavbarLink | - |
BlockAction
used by actions| Prop | Type | Default |
|---|---|---|
| appearance | ButtonAppearance"solid" | "soft" | "outline" | "transparent" | - |
| tone | ButtonTone"neutral" | "accent" | "destructive" | "success" | "warning" | "info" | - |
| icon | ReactNode | - |
| iconOnly | boolean | - |
| borderRadius | BlockActionBorderRadius"none" | "xs" | "sm" | "base" | "lg" | "xl" | "full" | - |
| labelrequired | string | - |
| linkrequired | string | - |
BlockMenuAction
used by actions| Prop | Type | Default |
|---|---|---|
| labelrequired | string | - |
| appearance | ButtonAppearance"solid" | "soft" | "outline" | "transparent" | - |
| tone | ButtonTone"neutral" | "accent" | "destructive" | "success" | "warning" | "info" | - |
| icon | ReactNode | - |
| iconOnly | boolean | - |
| borderRadius | BlockActionBorderRadius"none" | "xs" | "sm" | "base" | "lg" | "xl" | "full" | - |
| itemsrequired | BlockMenuItem[] | - |
BlockSocialLink
used by social| Prop | Type | Default |
|---|---|---|
| iconrequired | ReactNode | - |
| labelrequired | string | - |
| linkrequired | string | - |
NavbarLink
used by its parts| Prop | Type | Default |
|---|---|---|
| icon | ReactNode | - |
| description | string | - |
| active | boolean | - |
| labelrequired | string | - |
| linkrequired | string | - |
NavbarGroup
used by its parts| Prop | Type | Default |
|---|---|---|
| labelrequired | string | - |
| linksrequired | NavbarLink[] | - |
BlockMenuItem
used by its parts| Prop | Type | Default |
|---|---|---|
| labelrequired | string | - |
| icon | ReactNode | - |
| link | string | - |
| onSelect | () => void | - |
Icon links
social puts icon-only links in the bar, each named by its label, which also shows as a tooltip.