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/navbarThis 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
| Prop | Type | Default | Description |
|---|---|---|---|
Navbar: sticky | boolean | Default false | Keep the bar at the top of its scroll container while the content moves under it. |
Navbar: open | boolean | – | Whether the menu of a collapsed bar is open, when the parent holds the state. Use it with onOpenChange. |
Navbar: defaultOpen | boolean | Default false | Whether 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: sound | boolean | Default true | Play a soft sound when the menu opens and when it closes, if the visitor has sound on. |
Navbar: className | string | – | Extra classes for the bar itself, merged last: h-14 makes it taller, px-6 gives it more room at the sides. |
Navbar: ...props | ComponentProps<"header"> | – | Every other attribute, set on the header element around the bar. |
NavbarBrand | ComponentProps<"div"> | – | The product's mark and name. It is cut with an ellipsis before anything else when the bar is short of room. |
NavbarLinks: label | string | Default "Main" | The name of the navigation landmark and of the menu panel. |
NavbarLinks: children | ReactNode | – | 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: active | boolean | Default false | This link is the page being shown. It gets aria-current="page" and keeps the hover fill. |
NavbarLink: ...props | ComponentProps<"a"> | – | Every other link attribute. In the menu panel a press also closes the menu. |
NavbarActions | ComponentProps<"div"> | – | The slot at the end of the bar for buttons or an account menu. It stays in the bar at every width. |
NavbarToggle | button 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.
| Keys | Action |
|---|---|
| Tab | Move through the brand, the links, the actions and the menu button. |
| Enter / Space | On the menu button: open the menu. Focus moves to its first link. |
| Tab / Shift Tab | In the menu: move through its links. Moving the focus out of the menu closes it. |
| Enter | On a link: follow it. In the menu this also closes the menu. |
| Esc | Close the menu. Focus returns to the menu button. |
Source
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.0.0 · 2026-12-03First release.