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.jsonInterfaces that feel like glass.
NavbardefaultNavbarLabels
Floating pill
Click the items to watch the highlight morph.
import { useState } from "react";
import { Button } from "@/components/sheenui/button/button";
import { Navbar } from "@/components/sheenui/navbar/navbar";
// Package build (after the first npm release, or a packed tarball): import { Button, Navbar } from "@sheenui/theme";
// This example also uses button: npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/button.json
export function Example() {
const [active, setActive] = useState("home");
return (
<Navbar
aria-label="Main"
brand={<span>Sheen</span>}
items={[
{ value: "home", label: "Home" },
{ value: "work", label: "Work" },
{ value: "pricing", label: "Pricing" },
{ value: "blog", label: "Blog" },
]}
value={active}
onValueChange={setActive}
actions={<Button size="sm">Sign in</Button>}
/>
);
}Files to copy
7 folders · 8 files · 4 packages
- From
theme/src/ components/navbar/components/drawer/parts/sheet.tsxcomponents/popover/hooks/{use-latest.ts, use-media-query.ts, use-preferences.ts}motion/tokens.tslib/{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.tsmotion/gate.tslib/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.
import { useState } from "react";
import { Button } from "@/components/sheenui/button/button";
import { Navbar } from "@/components/sheenui/navbar/navbar";
// Package build (after the first npm release, or a packed tarball): import { Button, Navbar } from "@sheenui/theme";
// This example also uses button: npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/button.json
const items = [
{ value: "home", label: "Home" },
{ value: "work", label: "Work" },
{ value: "pricing", label: "Pricing" },
{ value: "blog", label: "Blog" },
];
export function Example() {
const [active, setActive] = useState("home");
return (
<Navbar
variant="bar"
aria-label="Main"
brand={<span>Sheen</span>}
items={items}
value={active}
onValueChange={setActive}
actions={<Button size="sm" variant="glass">Sign in</Button>}
/>
);
}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.
import { useState } from "react";
import { Button } from "@/components/sheenui/button/button";
import { Navbar } from "@/components/sheenui/navbar/navbar";
// Package build (after the first npm release, or a packed tarball): import { Button, Navbar } from "@sheenui/theme";
// This example also uses button: npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/button.json
const items = [
{ value: "home", label: "Home" },
{ value: "work", label: "Work" },
{ value: "pricing", label: "Pricing" },
{ value: "blog", label: "Blog" },
{ value: "docs", label: "Docs" },
{ value: "changelog", label: "Changelog" },
];
export function Example() {
const [active, setActive] = useState("home");
// Nothing to set up: the nav measures itself and folds when it must.
return (
<Navbar
aria-label="Main"
brand={<span>Sheen</span>}
items={items}
value={active}
onValueChange={setActive}
actions={<Button size="sm">Sign in</Button>}
labels={{ menu: "Menu" }} // the menu button's name; collapsible={false} scrolls instead
/>
);
}Props
Keyboard
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
Related pages
Guides that cover it
67 components pages in all: browse them on All components.
By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .