Skip to content
Thrum

Navbar

The bar across the top of an application: brand, primary links and actions. It follows the width of its own container, so in a narrow one the links move into a panel behind a menu button. For more than about six destinations, or for groups of them, use the sidebar.

Install

npx shadcn@latest add @thrum-pro/navbar

This is a Pro component. The command works once your project has a licence key: set up Pro or see pricing.

Automatically installs icons menu and x from the icon set.

Props

PropTypeDefaultDescription
Navbar: stickybooleanDefault falseKeep the bar at the top of its scroll container while the content moves under it.
Navbar: openboolean–Whether the menu of a collapsed bar is open, when the parent holds the state. Use it with onOpenChange.
Navbar: defaultOpenbooleanDefault falseWhether the menu starts open, when the navbar holds its own state.
Navbar: onOpenChange(open: boolean) => void–Called when the menu opens or closes, whatever caused it.
Navbar: soundbooleanDefault truePlay a soft sound when the menu opens and when it closes, if the visitor has sound on.
Navbar: classNamestring–Extra classes for the bar itself, merged last: h-14 makes it taller, px-6 gives it more room at the sides.
Navbar: ...propsComponentProps<"header">–Every other attribute, set on the header element around the bar.
NavbarBrandComponentProps<"div">–The product's mark and name. It is cut with an ellipsis before anything else when the bar is short of room.
NavbarLinks: labelstringDefault "Main"The name of the navigation landmark and of the menu panel.
NavbarLinks: childrenReactNode–NavbarLink elements, written once. They sit in a row in a bar at least 448 pixels wide, and fill the menu panel in a narrower one.
NavbarLink: activebooleanDefault falseThis link is the page being shown. It gets aria-current="page" and keeps the hover fill.
NavbarLink: ...propsComponentProps<"a">–Every other link attribute. In the menu panel a press also closes the menu.
NavbarActionsComponentProps<"div">–The slot at the end of the bar for buttons or an account menu. It stays in the bar at every width.
NavbarTogglebutton props–The menu button, named Menu. It shows only while the links are collapsed. Children replace its icon.

Motion and sound

Motion

  • The menu panel fades in and grows from 96% to full size over 150 ms, from the edge it shares with the bar. Closing plays it backwards, and a second press during it reverses it.
  • Links and the menu button change colour over 150 ms on hover.
  • The switch between the row of links and the menu button follows the container's width and happens at once.
  • Reduced motion: the panel appears and leaves at once.

Sound

  • A soft rising tone when the menu opens and a falling one when it closes by the button, Escape, a press outside or the focus leaving.
  • Following a link in the menu closes it without a sound: navigation is silent.

Sound is off until the visitor turns it on. Pass sound={false} to keep this component silent. How sound works

Accessibility

  • The bar sits in a header element and the links in a nav landmark named Main. Change the name with label when a page has two navigations.
  • The current page's link carries aria-current="page" and a fill, so it is not marked by colour alone.
  • The menu button is a native button named Menu with aria-expanded. It opens a dialog that is not modal: focus moves in, the rest of the page stays reachable, and Escape gives the focus back to the button.
  • While the row of links is hidden it is out of the tab order and out of the accessibility tree, and so is the menu button while the row shows.
  • A menu left open when the bar grows wide enough for its links closes by itself.
  • Under a glass material the bar and the menu panel are translucent. Their tints keep the text at 4.5 to 1 over any page.
KeysAction
TabMove through the brand, the links, the actions and the menu button.
Enter / SpaceOn the menu button: open the menu. Focus moves to its first link.
Tab / Shift TabIn the menu: move through its links. Moving the focus out of the menu closes it.
EnterOn a link: follow it. In the menu this also closes the menu.
EscClose the menu. Focus returns to the menu button.

Source

SourcePro

The source comes with Pro

TypeScript source · Copy-paste ready · MIT-compatible for client projects · Includes all dependencies

Files and dependencies

Adds
components/ui/navbar.tsx
Packages
@base-ui/react@1.9.0
Brings along
Sound engine
Icons
menux

Changelog

  1. 1.0.0 · 2026-12-03First release.

Loading index…

Keyboard shortcuts

/Ctrl KSearch components, docs and actions
?Show this list
AAppearance studio
SSound on or off
MFull or reduced motion
TTheme: auto, light, dark
GSurface: solid or frosted
BBackdrop photograph (under glass)
CCorner radius: square to round
RReplay the demo, on a component page
DDraw new data, on a component page
←→HomeEndMove the cursor in a focused chart
EscClose a dialog, or leave a chart cursor