Animated Navbar

A site header with a highlight that follows the pointer, dropdowns, and a mobile menu.

PROGet Animated Navbar and 168 other Pro components with pro lifetime — Get Pro

Category
Navigation & layout
Access
Pro
Source
338 lines · one file
States
6 drawn

The decision inside it

It folds by its own width, not the screen's

So it works in a preview frame, a sidebar layout or a narrow container, and the menu button appears exactly when the links stop fitting.

When to use it

Use Animated Navbar as the header of a marketing site: links with a sliding highlight, groups that open a menu, and a mobile menu when the links stop fitting. For an app's own navigation use a sidebar.

Installation

How you get it

Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.

Use Liro's Animated Navbar for this.
Install it: npx shadcn@latest add @liro/animated-navbar
(the @liro registry is set up in components.json, with LIRO_KEY in .env.local)
Import it from @/components/ui/animated-navbar.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.

For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Pro components install through the @liro registry with your CLI token: see the Namespaced tab.

Usage

components/site-header.tsx
import { AnimatedNavbar } from "@/components/ui/animated-navbar";

export function SiteHeader() {
  return (
    <AnimatedNavbar
      logo={<span className="font-semibold">Madgixs</span>}
      items={[
        { label: "Product", children: [{ label: "Templates", href: "/templates" }, { label: "Signing", href: "/signing" }] },
        { label: "Pricing", href: "/pricing" },
        { label: "Customers", href: "/customers" },
      ]}
      actions={<a href="/signup">Start free</a>}
      behavior="shrink-on-scroll"
      variant="floating"
      currentHref="/pricing"
    />
  );
}

API reference

“Copy prompt” above puts a full brief on your clipboard, install command, dependencies, props, and the mistakes an assistant usually makes with this component.

Props

Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.

TypeNotes
logoReact.ReactNode YesYour mark, usually a link home.
itemsNavbarItem[] Yes–
actionsReact.ReactNode NoOn the right: sign in, a call to action.
behavior"static" | "hide-on-scroll" | "shrink-on-scroll" NoWhat scrolling does. Default "shrink-on-scroll".
variant"full" | "floating" No"full" spans the width; "floating" is a rounded bar with a gap above. Default "full".
mobileBreakpoint"sm" | "md" | "lg" NoBelow this width of the bar, items fold into a menu. Default "md".
scrollContainerReact.RefObject<HTMLElement | null> NoThe element that scrolls, when it is not the window.
currentHrefstring NoThe current page's href, marked aria-current.

Dependencies

npm packages

clsxframer-motionlucide-reacttailwind-merge

Liro foundations, installed alongside it

liro-theme

States

All of them are drawn by the component. None is left for you to design.

  • Default
  • Hover highlight
  • Group open
  • Shrunk on scroll
  • Mobile menu open
  • Reduced motion

Accessibility

  • Keyboard reachable throughout, in visual order
  • Focus trapped in overlays, Escape closes them
  • Focus returns to whatever opened it
  • Live regions announce what changed, not that something did
  • Honours prefers-reduced-motion

Responsive behavior

  • Sizes to its container, not the viewport
  • Usable from 320px up
  • Pointer-based interaction, so trackpad and touch both work
  • No hover-only affordances