Navbar
Top navigation with a brand, links and an action; links fold into a no-JS menu on phones.
Preview
Sticks to the top, slides away while you scroll down and comes back as soon as you scroll up or tab into it. 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 { Navbar } from "@/components/custom/navbar";
<Navbar
brand="Acme"
links={[
{ label: "Features", href: "/features" },
{ label: "Pricing", href: "/pricing" },
]}
action={{ label: "Get started", href: "/signup" }}
/>import { NavbarMotion } from "@/components/custom/navbar/navbar-motion";
<NavbarMotion {...props} />Props
| Prop | Type | Default | Description |
|---|---|---|---|
| brand* (required) | string | – | Name shown on the left, linked to brandHref. |
| brandHref | string | "/" | Where the brand links to. |
| links* (required) | { label: string; href: string }[] | – | Main navigation links. |
| action | { label: string; href: string } | – | Optional call to action on the right. |
| ...props | React.ComponentProps<"header"> | – | Any other header attribute (id, aria-*, data-*, ref) goes to the root element. |
| Prop | Type | Default | Description |
|---|---|---|---|
| brand* (required) | string | – | Name shown on the left, linked to brandHref. |
| brandHref | string | "/" | Where the brand links to. |
| links* (required) | { label: string; href: string }[] | – | Main navigation links. |
| action | { label: string; href: string } | – | Optional call to action on the right. |
| ...props | React.ComponentProps<"header"> | – | Any other header attribute (id, aria-*, data-*, ref) goes to the root element. |
Accessibility
- Links sit in a <nav aria-label="Main">.
- On phones the links fold into a details/summary menu that works without JavaScript; the toggle is labelled “Menu”.
- The motion version follows the visitor's reduced-motion setting and never hides content before it animates.