new course
CSS grid landing page tutorial (36min)

Lesson info

Lesson info

The menu button is an element inside the navbar that organizes the nav links when there is limited horizontal space, like on a mobile device. It's sometimes referred to as the “hamburger menu.”

The menu button and its functionality are built into the navbar element, and can be accessed and configured in a number of ways. We’ll cover four aspects of the menu button:

  1. Triggering the menu
  2. Setting which breakpoints the menu displays on
  3. Animating the menu
  4. Styling the menu button

Explore this project

Want to dig into the project featured in this video and see how everything is put together? We've included the full project we used when making this lesson, and we've shared the link right under this very paragraph.

View and clone this projectDownload lesson assets
Clone this projectDownload project assets


The menu button is an excellent alternative to horizontally cramming multiple menu links.

And it goes by many names. As a visual abstraction, the common menu button can remind us of a hamburger. Or gluten-free pancakes.

The menu button is built right into the default Navbar element. And it can be accessed and configured in a number of ways. We'll cover four aspects of the menu button: we're going to look at the Trigger itself (what's happening when we press the button), we'll look at Device visibility (how it shows up on different devices), then Menu types (some of the options we have there), and finally, styling our menu button.

As we already know, our nav links are enclosed in a nav menu, and we can see that in our Navigator. Now, that nav menu is actually the same element that shows up when we press the menu button.

And to demonstrate this, we can set a background color on this nav menu, like salmon. And two things happen. 1. Our design becomes hideous. And 2. We can see that the color we set cascades down to our Tablet view, and we can see that hideousness when we press the menu button. It's the same element. Inheriting that same color.

Now, a quick way to trigger that menu button from any view inside the Designer, is to click an element inside of our Navbar, go to Element Settings, and press Open Menu. Notice how the Designer automatically switched the view to Tablet. That's because if we go back to Desktop, our Nav Menu is already expanded. There is no menu button here; by default the Tablet view is the first to show a menu button.

So, let's go to Preview, and when we're in Tablet mode or below, our menu button appears. And pressing that button expands our nav menu. Pressing the menu button again, the nav menu collapses.

That's what happens when we press the menu button.

Let's talk about visibility on different devices.

As we already know, the menu button is visible starting on Tablet screenwidths, but you can modify this. Again, we can select anything inside our nav bar, and under Element Settings, we have device options right here at the bottom. If we want to show the full menu bar on Tablet, and we only want to display the button on phones, for instance, we can adjust that visibility by shifting down.

If we move over to Tablet view, the menu button doesn't show. Now we have all our nav links visible in our nav menu. Go down one more view, we have our menu button. Let's go back to the default view.

What if we always want the menu bar? Then we just shift up. Menu bar visible on the default view, as well. For now, let's put it back to Tablet.

That's device visibility.

Next we have menu types.

And to access these types, simply select any element inside our nav bar, visit our Element Settings Panel, and have a look right inside our Navbar Settings. We have three options here in our drop-down: coincidentally, the first — and default option— is "Drop Down." We also have Over Right. Let's take a look at that in Preview. We'll go to the Tablet view so our menu button is visible, and when we press? The menu comes in over the right side of our viewport. Press anywhere outside of it? And it collapses.

Let's go back.

Now this next completely different. And we can access it the same way under our Element Settings Panel. This is Over Left. And when we preview it now? When we go to access our menu button, the comes in from the left.

Let's click out. And go back again. And for all these menu types. You can of course control the type of easing curve that's used to animate the open and close transitions, and you can change the duration. Let's say 47,000 milliseconds...which is of course 47 seconds. We'll preview again? And trigger the menu button. Let's watch.

This is a good time for a little macOS trivia...if you're running macOS. Hold down shift, and minimize any window. Watching the result is scientifically proven to reduce stress. And for our menu here, we'll watch this open animation all the way through. Our editor's gonna let the whole thing play out for--

And that's menu types. Finally, let's cover styling.

Now you can style any aspect of the navbar, or the nav menu. We're going to focus on the menu button here.

When we're in tablet view, for instance, and we select our menu button, we can see that there's no color set for the background. If you want to change that background color, of course, here's the place to do that.

And for the little hamburger icon, we can style that, too. And the best way to do that is to change the typography settings on its parent element. That's the menu button itself!

Want to change the size of the menu icon? We can adjust our font size. Want to change the color? We can style that from the Menu Button here as well. Because the menu icon is inheriting these typography styles from its parent — the menu button — these changes are affecting the menu icon.

And we can go back over and open our menu again and we can make the same kinds of style changes here. For instance, if we want to change the menu icon color on the Open state — once the menu is opened — we can do that here, too.

So. When we press the menu button, it triggers the display of the nav menu. We can adjust the visibility of the menu button based on the device being used. We can have our nav menu drop down, or come in from the right, or we can even have it come in from the left. And we can adjust styles on our menu button, including typography styles, which will pass down to the menu icon.

That's the menu button.