Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Animated Hamburger Navbar Block for React

A menu-first navbar for a ceramics studio: a wordmark, a Shine Button and a hamburger whose three lines turn into a cross, opening a full-width card of six links that ease in one after the other.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

An animated hamburger navbar for React with Base UI, the bar for sites that keep their navigation behind one button. The wordmark leads, a Book a class Shine Button sits beside the menu button, and the menu button is on the bar at every width: that is the feature, so it shows on a desktop too. Three lines turn into a cross with CSS transforms when the menu opens, and a full-width card drops under the bar over the page with six links, each a name and a line about what's behind it, easing in one after the other from the start edge; the current page is tinted. The button says whether the menu is open and which panel it controls, Escape, a click outside or focus moving away closes the card, and focus goes back to the button. The block stays one bar high (56 pixels), the card opens over the page, and the page's rails and top rule come from the Guides spine: the bar draws no bottom border, because the next block's top rule is its bottom edge. It's built from Button, Shine Button and Guides, with your theme's tokens for every colour. For portfolios, studios, shops and any site whose pages deserve more room than a row of links.

FAQ

How does the hamburger turn into a cross?

It's three spans, each a 2-pixel line. The button's own aria-expanded drives them (group-aria-expanded/menu: classes): the top line moves down and turns 45 degrees, the bottom one moves up and turns the other way, and the middle one shrinks away, all over 300 ms with CSS transitions on translate, rotate, scale and opacity. Nothing is measured and no animation library is involved. With reduced motion the lines change at once.

How do the links ease in one after the other?

Each link's li gets its position in a CSS variable (--i) and waits --i × 45 ms + 80 ms before it slides in from the start edge and fades up, so the six land over about 350 ms. Closing the card is not staggered: everything fades together. The slide follows the reading direction, so it comes from the other side in right-to-left layouts, and with reduced motion the links are simply there when the card opens.

How does it work with a keyboard and a screen reader?

The button is named Menu and says whether it's expanded; its aria-controls points at the card, a nav landmark named Main. While the card is closed it is inert and invisible, so Tab goes straight past it and a screen reader doesn't read it; open, Tab walks into its links. Escape closes the card and puts focus back on the button, clicking outside it or tabbing out of the header closes it too, and choosing a link closes it so a client-side route change doesn't leave it open over the next page. This is plain markup and the same on every target. Shine Button renders the link it's given with render, with nativeButton={false}.

Can it show inline links on a desktop and keep the hamburger for phones?

Yes. Add md:hidden to the menu button and to the card, and a nav with the same links (from PAGES) and max-md:hidden on the bar next to the wordmark. This block keeps the button at every width so the menu is what you see in a gallery.

How does it sit on the page, and can it stick to the top?

It's the page's first block: its + marks and rails line up with every block under it, its top rule falls on the window's top edge (or between it and a banner above it), and the card opens over the page so nothing below moves. To keep the bar in view while the page scrolls, add sticky top-0 z-40 bg-background/80 backdrop-blur to the header; the card then rides along under it. Every link points at #: point them at your pages.

  • Pro

    Drill-Down Drawer Navbar

    Mobile and drawers

    A drawer navbar for a travel planner: a Menu button at every width opens a sheet from the end where Plan and Explore slide a second panel in with a Back button, with Pricing and Help centre as plain links and a Shine Button at the foot.

  • Pro

    Fullscreen Overlay Navbar

    Mobile and drawers

    A full-screen menu navbar for an architecture studio: a two-line menu button at every width opens a sheet that fills the screen with five large numbered links on hairline rows that fade up one after the other.

  • Pro

    Priority Plus Navbar

    Cells and splits

    A priority-plus navbar for a media-planning suite in a resizable frame: the links that fit stay on the bar and the rest drop into a More menu as you drag the frame narrower, decided by container queries.

  • Pro

    Bottom Tab Bar Navbar

    Mobile and drawers

    A bottom tab bar for a running-diary app: five cells on shared hairlines, four links with a filled current tab and an unread dot, and a raised Shine Button that opens a drawer from the bottom with three ways to create.

  • Pro

    Minimal Navbar

    Link highlights

    The least navbar there is: a slim 48 px bar with a wordmark, three plain links and one Shine Button for a journaling app, with no motion, the current page marked by weight and a dot, and a bottom drawer on phones.

  • Pro

    Floating Pill Navbar

    Surface and theme

    A detached opaque pill navbar that hugs its content and floats centred in the page column, with the call to action inside it and a drawer menu on phones.