Navbar: floating
A pill-shaped navbar floating over the page; links fold into a no-JS menu on phones.
Preview
Once you scroll, the pill tightens slightly and lifts with a deeper shadow. With reduced motion turned on, it renders the plain layout.
Installation
Run this in a project that already uses shadcn/ui. It adds the component and anything it needs; the motion version also adds the plain one and the motion package.
Usage
import { NavbarFloating } from "@/components/custom/navbar-floating";
<NavbarFloating
brand="Acme"
links={[{ label: "Pricing", href: "/pricing" }]}
action={{ label: "Sign up", href: "/signup" }}
/>import { NavbarFloatingMotion } from "@/components/custom/navbar-floating/navbar-floating-motion";
<NavbarFloatingMotion brand="Acme" links={links} />Props
| Prop | Type | Default | Description |
|---|---|---|---|
| brand* (required) | string | – | Name at the left, linked to brandHref. |
| brandHref | string | "/" | Where the brand links. |
| links* (required) | { label; href }[] | – | Main navigation. |
| action | { label; href } | – | Button at the right. |
| ...props | React.ComponentProps<"header"> | – | Any other header attribute goes to the root element. |
| Prop | Type | Default | Description |
|---|---|---|---|
| brand* (required) | string | – | Name at the left, linked to brandHref. |
| brandHref | string | "/" | Where the brand links. |
| links* (required) | { label; href }[] | – | Main navigation. |
| action | { label; href } | – | Button at the right. |
| ...props | React.ComponentProps<"header"> | – | Any other header attribute goes to the root element. |
Accessibility
- Links sit in a nav labelled “Main”; on phones they fold into a details/summary menu labelled “Menu”.
- The motion version follows the visitor's reduced-motion setting and never hides content before it animates.