Skip to Content
zjkm-ui
Components

Hamburger Navbar

A navbar whose menu icon morphs into a close button.

Props
720px
<HamburgerNavbar brand="Acme" links={links} />

Installation

npx shadcn@latest add https://ui.zjkm.tech/r/hamburger-navbar.json
import { HamburgerNavbar } from "@/components/hamburger-navbar"

Using JavaScript? Set tsx: false in components.json and the CLI converts it.

New to shadcn? Run npx shadcn@latest init first. The CLI needs components.json and the @/ import alias.

Usage

A navbar whose links fold into a menu when its container is narrow, using a container query, so it adapts wherever you put it. The menu icon morphs into a close icon, and Escape closes the menu. Narrow the demo to see it.

import { HamburgerNavbar } from "@/components/hamburger-navbar";

export function SiteHeader() {
  return <HamburgerNavbar brand="Acme" links={[{ label: "Docs", href: "/docs" }, { label: "Blog", href: "/blog" }]} />;
}

Props

PropTypeDefaultDescription
brandReactNodeYour logo or name.
links{ label, href }[]The links.
currentstringThe current page's href.
classNamestringClasses for the root element.

With reduced motion, the icon and menu change without animating.

On this page