Skip to content

Glassmorphism Navbar for React

A glassmorphism navbar for React comes in two forms: a floating Apple-style pill whose highlight morphs between items, and a full-width top bar with a sliding underline.

npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/navbar.json

Interfaces that feel like glass.

Floating pill

Click the items to watch the highlight morph.

Files to copy

7 folders · 8 files · 4 packages
From theme/src/
  • components/navbar/
  • components/drawer/parts/sheet.tsx
  • components/popover/
  • hooks/{use-latest.ts, use-media-query.ts, use-preferences.ts}
  • motion/tokens.ts
  • lib/{cn.ts, form.ts, popup-motion.ts}
  • styles/
shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/navbar.jsonRegistry item: navbar. The styles need the Tailwind v4 glass UI setup.
The examples also use
  • components/button/
  • components/spinner/
  • hooks/use-magnetic.ts
  • motion/gate.ts
  • lib/state-light.tsx
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/button.json
Packages
pnpm add @base-ui/react clsx motion tailwind-merge

Full-width bar

variant="bar": for app headers. The underline slides to the active item.

Folds into a menu

When the items don't fit next to the brand and actions, they fold into a menu button. It opens a glass popover listing every item, with the current one checked; choosing one closes it and returns focus to the button. Pick a width to watch it fold and unfold.

Props

PropTypeDefaultDescription
items (required)NavbarItem[]NoneTakes the navigation items, in order.
value (required)stringNoneSets the value of the active item when controlled.
onValueChange((value: string) => void)NoneCalled with an item's value when it is chosen (a plain left click on a link also calls it).
brandReactNodeNoneShows the logo or product name on the left.
actionsReactNodeNoneButtons on the right (theme toggle, sign in, ...).
renderLink((props: NavLinkProps, item: NavbarItem) => ReactElement)a plain <a>Render items that have an href through your router's link component. See NavLinkProps.
shrinkOnScrollnumber | false24Once the page scrolls past this many px, the bar tightens and turns more opaque (the floating pill also shrinks a touch). false turns it off.
hideOnScrollnumber | booleanfalseSlide the bar out of view while scrolling down and bring it back on any scroll up. true starts hiding after 64px; pass a number for a different distance. Make the navbar sticky or fixed for this to make sense.
scrollContainerRefObject<HTMLElement | null>NoneTrack this element's scroll instead of the window's (e.g. an app shell's scrolling <main>).
variant"floating" | "bar""floating""floating" = centred glass pill, highlight morphs between items (Apple style). "bar" = full-width top bar, a sliding underline marks the active item.
collapsiblebooleantrueWhen the items don't fit next to the brand and actions (phones, narrow containers), fold them into a menu button that opens a glass popover. false lets them scroll sideways instead.
labelsPartial<NavbarLabels>defaultNavbarLabelsEvery string, for translation: { menu: "Menu", name: "Main" } (accessible name of the menu button shown when the items are folded away, and the default landmark name). Every other string, for translation: labels={{ menu: "…" }}; omitted keys keep the English of defaultNavbarLabels. All 2 keys of NavbarLabels are listed in the key table under the props table.
aria-labelstringlabels.nameLandmark name. Give each navigation on a page its own, e.g. "Main" and "Account".
classNamestringNoneExtra classes for the <nav> (position it with sticky, fixed or margins).
NavbarLabels keys and English defaults (2)
Pass any key in labels; the rest keep the defaults of defaultNavbarLabels.
KeyEnglish default
menuMenu
nameMain

Keyboard

KeysAction
Tab/Shift + TabMove through the brand, items and actions.
EnterFollow a link or select an item.
Arrow Down/Arrow Up/Home/EndIn the folded menu: move between items.
EscapeClose the folded menu and return focus to the menu button.

Accessibility

  • A <nav> landmark: pass aria-label ("Main") and give a second bar a different name. The current item has aria-current="page".
  • A bar hidden by hideOnScroll comes back when focus enters it, so keyboard users never tab into an off-screen bar.
  • The folded menu button reports aria-expanded and is named by labels.menu. Targets are 44 px on touch screens.

All exports on this page

  • Navbar — Horizontal navigation.
  • defaultNavbarLabels — The English NavbarLabels used when labels is omitted; a partial labels prop is merged over it.

When to use Navbar

  • Use it as a floating navbar, the glass pill, for a marketing site header with four or five destinations, where the highlight morphing between Home, Work, Pricing and Blog gives the page a polished, app-like first impression.
  • Use variant="bar" for the top of a dashboard or documentation app, where a full-width header with a sliding underline and a Sign in action on the right is what users expect.
  • It suits sites that must work on phones without a second mobile menu, because items that no longer fit next to the brand and actions fold into a menu button on their own.
  • Skip it when your destinations open rich dropdown panels with descriptions and images; Navigation menu is built for that, while this component is a flat list of links or buttons.
  • Pair it with Button for the Sign in action, GlassCard for the page sections underneath, and Avatar in the actions slot to show the signed-in user.

Frequently asked questions

67 components pages in all: browse them on All components.

By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .