Hamburger
Menu button whose three lines cross into an X.
$npx shadcn@latest add https://framebrick.co/r/hamburger.jsonFrom the Nitip template, see it in context.
Studio
"use client";
import { useState } from "react";
import { Hamburger } from "@/components/ui/hamburger";
export default function HamburgerDemo() {
const [open, setOpen] = useState(false);
return (
<div className="w-full max-w-sm rounded-lg border bg-card">
<div className="flex items-center justify-between px-4 py-3">
<span className="text-sm font-semibold">Studio</span>
<Hamburger open={open} onOpenChange={setOpen} controls="hamburger-demo-menu" />
</div>
<div id="hamburger-demo-menu" hidden={!open} className="border-t px-4 py-3 text-sm text-muted-foreground">
Work · Studio · Journal · Contact
</div>
</div>
);
}Examples
Uneven lines
Three lines of different lengths that grow to the same width as they cross.
Studio
"use client";
import { useState } from "react";
import { Hamburger } from "@/components/ui/hamburger";
export default function HamburgerUnevenDemo() {
const [open, setOpen] = useState(false);
return (
<div className="w-full max-w-sm rounded-lg border bg-card">
<div className="flex items-center justify-between px-4 py-3">
<span className="text-sm font-semibold">Studio</span>
<Hamburger open={open} onOpenChange={setOpen} controls="hamburger-uneven-demo-menu" lines="uneven" labels={false} />
</div>
<div id="hamburger-uneven-demo-menu" hidden={!open} className="border-t px-4 py-3 text-sm text-muted-foreground">
Work · Studio · Journal · Contact
</div>
</div>
);
}<Hamburger open={open} onOpenChange={setOpen} controls="main-menu" lines="uneven" labels={false} />Installation
$ npx shadcn@latest add https://framebrick.co/r/hamburger.json1. Install the dependencies.
npm install motion clsx tailwind-merge2. Add
cn()tolib/utils.ts(skip if shadcn already created it).import { clsx, type ClassValue } from "clsx"; import { extendTailwindMerge } from "tailwind-merge"; /* tailwind-merge must know the site's type scale (globals.css) is a font size, not a text color — otherwise cn("text-h6 text-muted-foreground") drops text-h6. */ const twMerge = extendTailwindMerge({ extend: { classGroups: { "font-size": [{ text: ["display", "h1", "h2", "h3", "h4", "h5", "h6"] }] } }, }); export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); }3. Copy the component into
components/ui/hamburger.tsx."use client"; import * as React from "react"; import { motion, type Transition } from "motion/react"; import { cn } from "@/lib/utils"; /* * Hamburger — menu button whose three lines cross into an X (from the Nitip header). * The lines move with Framer's soft spring (no bounce, 0.4s); the label switches with the state. * Controlled (`open` + `onOpenChange`) or on its own; point `controls` at the id of the menu it opens. * * `lines="uneven"` is Ciketo's: a 26 × 14 box, lines right-aligned at 75%, 100% and 50% wide. Opening, the outer * lines grow to the full width, meet in the middle and turn ±45° while the middle one fades — on a spring with a little * bounce (0.2), as Ciketo's. */ const springs = { even: { type: "spring", bounce: 0, duration: 0.4 }, uneven: { type: "spring", bounce: 0.2, duration: 0.4 }, } satisfies Record<string, Transition>; const shapes = { even: { box: "h-3 w-4", edge: "left-0", mid: 5.5, bottom: 11, widths: ["100%", "100%", "100%"] }, uneven: { box: "h-3.5 w-[26px]", edge: "right-0", mid: 6.5, bottom: 13, widths: ["75%", "100%", "50%"] }, } as const; export type HamburgerProps = { open?: boolean; defaultOpen?: boolean; onOpenChange?: (open: boolean) => void; /** id of the element this button shows and hides. */ controls?: string; /** Labels beside the lines; `false` hides them. */ labels?: { closed: string; open: string } | false; /** "even": three equal lines. "uneven": right-aligned lines at 75%, 100% and 50% of the width. */ lines?: "even" | "uneven"; className?: string; }; export function Hamburger({ open, defaultOpen = false, onOpenChange, controls, labels = { closed: "Menu", open: "Close" }, lines = "even", className, }: HamburgerProps) { const [internal, setInternal] = React.useState(defaultOpen); const isOpen = open ?? internal; function toggle() { const next = !isOpen; if (open === undefined) setInternal(next); onOpenChange?.(next); } const shape = shapes[lines]; const spring = springs[lines]; const line = cn("absolute h-px bg-current", shape.edge); return ( <button type="button" aria-expanded={isOpen} aria-controls={controls} aria-label={labels ? undefined : isOpen ? "Close menu" : "Open menu"} onClick={toggle} className={cn( "inline-flex cursor-pointer items-center gap-2 rounded-md text-sm font-medium text-foreground", "outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50", className, )} > {labels && (isOpen ? labels.open : labels.closed)} <span aria-hidden className={cn("relative", shape.box)}> <motion.span className={line} initial={false} animate={isOpen ? { top: shape.mid, rotate: 45, width: "100%" } : { top: 0, rotate: 0, width: shape.widths[0] }} transition={spring} /> <motion.span className={line} style={{ top: shape.mid, width: "100%" }} initial={false} animate={{ opacity: isOpen ? 0 : 1 }} transition={spring} /> <motion.span className={line} initial={false} animate={ isOpen ? { top: shape.mid, rotate: -45, width: "100%" } : { top: shape.bottom, rotate: 0, width: shape.widths[2] } } transition={spring} /> </span> </button> ); }
Usage
import { Hamburger } from "@/components/ui/hamburger";
const [open, setOpen] = useState(false);
<Hamburger open={open} onOpenChange={setOpen} controls="main-menu" />
<nav id="main-menu" hidden={!open}>…</nav>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| open | boolean | — | Open state (controlled). |
| defaultOpen | boolean | false | Initial state (uncontrolled). |
| onOpenChange | (open: boolean) => void | — | Called when the button is pressed. |
| controls | string | — | id of the menu this button shows and hides (aria-controls). |
| labels | { closed, open } | false | { closed: "Menu", open: "Close" } | Text beside the lines; false hides it and sets an aria-label instead. |
| lines | "even" | "uneven" | "even" | Three equal lines, or right-aligned lines at 75%, 100% and 50% of the width (Ciketo's). Opening, the outer lines of the uneven one grow to the full width before they cross, on a spring with a little bounce. |
AI prompt
Paste into v0, Lovable, Bolt or Claude to rebuild this component in your own project.
Create a React + Tailwind CSS + Motion (motion/react) component called Hamburger.
- A button with an optional label ("Menu" / "Close", text-sm font-medium) and three 1px lines in a 16x12 box.
- Open: the top line moves to the middle and rotates 45°, the bottom line moves to the middle and rotates -45°,
the middle line fades out. Spring with no bounce, duration 0.4s.
- Controlled (open + onOpenChange) or uncontrolled (defaultOpen).
- Accessibility: aria-expanded, aria-controls pointing at the menu, an aria-label when the text label is hidden,
visible focus ring (ring-[3px] ring-ring/50).
- A lines prop, "even" by default. "uneven" is a 26 x 14 box with the lines right-aligned at 75%, 100% and 50% of the width;
opening, the outer lines grow to the full width, meet in the middle and turn ±45° while the middle one fades, on a spring
with a little bounce (0.2).










