How to Add a Hamburger Icon Toggle to Divi’s Menu Module on Desktop

Last Updated on September 16, 2022 by 10 Comments

How to Add a Hamburger Icon Toggle to Divi’s Menu Module on Desktop
Blog / Divi Resources / How to Add a Hamburger Icon Toggle to Divi’s Menu Module on Desktop

If you’re building your header inside Divi, there are quite a few ways to go about it. As a matter of fact, you can get an overview on header types and tutorials here. Now, in today’s tutorial, we’re adding another option to your list. We’ll show you how to add a hamburger icon toggle to DIvi’s Menu Module. This hamburger icon appears, by default, on smaller screen sizes already, but in this tutorial, we’ll make sure a hamburger icon appears on desktop as well. When clicking the hamburger icon, all menu items will appear in a horizontal order next to the icon. This gives a minimal look and feel to your header while adding interaction as well. You will be able to download the template JSON file for free as well!

Let’s get to it.

Preview

Before we dive into the tutorial, let’s take a quick look at the outcome across different screen sizes.

hamburger icon toggle

Download The Global Header Template for FREE

To lay your hands on the free global header template, you will first need to download it using the button below. To gain access to the download you will need to subscribe to our newsletter by using the form below. As a new subscriber, you will receive even more Divi goodness and a free Divi Layout pack every Monday! If you’re already on the list, simply enter your email address below and click download. You will not be “resubscribed” or receive extra emails.

1. Create New Global Header Template

Go to Divi Theme Builder

Start by going to the Divi Theme Builder in the backend of your WordPress website. Once there, click on “Add Global Header”.

hamburger icon toggle

Add New Global Header

A dropdown menu will appear. To start building from scratch, continue by selecting “Build Global Header”.

hamburger icon toggle

2. Create Global Header Design

Section Settings

Background Color

Once inside the template editor, it’s time to start building the header design. You’ll notice there’s a section there already. Open the section’s settings and add a background color.

  • Background Color: #f6f9fb

hamburger icon toggle

Spacing

Move on to the section’s design tab and remove all default top and bottom padding.

  • Top Padding: 0px
  • Bottom Padding: 0px

hamburger icon toggle

Add New Row

Column Structure

Continue by adding a new row using the following column structure:

hamburger icon toggle

Sizing

Without adding modules yet, open the row settings, go to the design tab and modify the max width in the sizing settings.

  • Max Width: 1280px

hamburger icon toggle

Spacing

Modify the top and bottom padding in the spacing settings next.

  • Top Padding: 5px
  • Bottom Padding: 5px

hamburger icon toggle

Add Menu Module to Column

Select Menu

Next, add a Menu Module to the row’s column and select a dynamic menu of your choice.

hamburger icon toggle

Upload Logo

Upload a logo.

hamburger icon toggle

Remove Background Color

Then, remove the module’s default white background color.

hamburger icon toggle

Menu Text Settings

Move on to the module’s design tab and change the menu text settings accordingly:

  • Menu Font: Poppins
  • Menu Font Weight: Semi Bold
  • Menu Text Color: #003e51
  • Menu Text Size: 16px
  • Text Alignment: Right

hamburger icon toggle

Dropdown Menu Settings

Change the dropdown menu settings next.

  • Dropdown Menu Line Color: #7159c8

hamburger icon toggle

Icons Settings

Modify the icons settings too.

  • Shopping Cart Icon Color: #670fff
  • Search Icon Color: #670fff
  • Hamburger Menu Icon Color: #670fff

hamburger icon toggle

Sizing

Then, go to the sizing settings and assign a logo max width.

  • Logo Max Width: 50px

hamburger icon toggle

Spacing

Remove the module’s default bottom margin too.

  • Bottom Margin: 0px

hamburger icon toggle

Turn Section Sticky

Now that our menu is in place, we’ll turn the section sticky as well. Open the section settings, go to the advanced tab and apply the following sticky settings:

  • Sticky Position: Stick to Top
  • Offset From Surrounding Sticky Elements: Yes
  • Transition Default and Sticky Styles: Yes

hamburger icon toggle

Sticky Background Color

Modify the section’s background color in a sticky state next.

  • Background Color: #ffffff

hamburger icon toggle

Sticky Box Shadow

Apply a box shadow to the section as well.

  • Default Shadow Color: rgba(0,0,0,0)
  • Sticky Shadow Color: rgba(0,0,0,0.04)

hamburger icon toggle

3. Add Hamburger Icon Toggle to Menu Module

Add CSS ID to Menu Module

In the next part of the tutorial, we’ll focus on creating the desktop hamburger icon toggle icon. First, open the Menu Module’s settings, go to the advanced tab and assign a CSS ID.

  • CSS ID: divi-menu

hamburger icon toggle

Add Code Module Below Menu Module

Then, add a Code Module below the Menu Module.

hamburger icon toggle

Add Script & Style Tags

We’ll be using some CSS and JQuery code. To prepare for that, we’ll add some style and script tags.

hamburger icon toggle

Add CSS Code

We’ll paste the following lines of CSS code between the style tags:

.toggle-icon:after {
content: "\61";
font-size: 32px;
font-family: ETmodules !important;
color: #003e51;
position: absolute;
top: 26px;
right: 0;
cursor: pointer;
}

#divi-menu .et_pb_menu__menu>nav {
margin-right: 38px;
visibility: hidden;
opacity: 0;
  
-webkit-transition: .1s ease-in-out;
-moz-transition: .1s ease-in-out;
-o-transition: .1s ease-in-out;
transition: .1s ease-in-out;
  
transform: translateY(50%);  
}
  
.reveal-menu-items {
opacity: 1 !important;
visibility: visible !important;
transform: translateY(0%) !important;
}
  
.icon-switch:after {
content: '\4d';
font-size: 32px;
font-family: ETmodules !important;
color: #003e51;
position: absolute;
top: 26px;
right: 0;
cursor: pointer;    
}

hamburger icon toggle

Add JQuery

Add JQuery Opening Code Lines

Up next, we’ll have the JQuery code. Add the following lines of JQuery code between the script tags:

jQuery(function($){
$(document).ready(function(){

});
});

hamburger icon toggle

Create Variables

Create some variables next.

var toggleIcon = $('<div class="toggle-icon"></div>');
var desktopMenu = $('#divi-menu .et_pb_menu__menu>nav');

hamburger icon toggle

Place Toggle Icon Inside Menu Module

Then, place the toggle icon variable inside the Menu Module using this following code line:

toggleIcon.insertAfter(desktopMenu);

hamburger icon toggle

Add Click Function

We’re adding a click function as well.

toggleIcon.click(function(){
	desktopMenu.toggleClass('reveal-menu-items');
  $(this).toggleClass('icon-switch');
});

hamburger icon toggle

4. Save Divi Theme Builder Changes

Now that everything is in place, the only thing left to do is save all Divi Theme Builder changes and view the outcome!

hamburger icon toggle

hamburger icon toggle

Preview

Now that we’ve gone through all the steps, let’s take a final look at the outcome across different screen sizes.

hamburger icon toggle

Final Thoughts

In this post, we’ve shown you how to get creative with your Divi header inside the Divi Theme Builder. More specifically, we’ve shown you how to add a hamburger menu icon toggle on desktop as well. By default, a hamburger icon is part of the tablet and mobile experience, but we’re extending this to desktop as well. When clicking the toggle icon, the menu items will appear in a horizontal order, which gives this a minimal look and feel. You were able to download the template JSON file for free as well! If you have any questions or suggestions, make sure to leave a comment in the comment section below.

If you’re eager to learn more about Divi and get more Divi freebies, make sure you subscribe to our email newsletter and YouTube channel so you’ll always be one of the first people to know and get benefits from this free content.

Divi Marketplace

Are You A Divi User? Find Out How To Get More From Divi! 👇

Browse hundreds of modules and thousands of layouts.

Visit Marketplace
Divi Marketplace
Divi Cloud

Find Out How To Improve Your Divi Workflow 👇

Learn about the new way to manage your Divi assets.

Get Divi Cloud
Divi Cloud
Divi Hosting

Want To Speed Up Your Divi Website? Find Out How 👇

Get fast WordPress hosting optimized for Divi.

Speed Up Divi
Divi Hosting
Premade Layouts

Check Out These Related Posts

New Starter Site for Estheticians (Quick Install)

New Starter Site for Estheticians (Quick Install)

Posted on November 12, 2024 in Divi Resources

Divi empowers you to build the best websites possible, and now, Divi Quick Sites takes website creation to a whole new level. This revolutionary tool lets anyone, regardless of skill level, generate a complete website in under two minutes! Divi Quick Sites provides everything you need to launch...

View Full Post
Divi 5 Update: Public Alpha Version 3

Divi 5 Update: Public Alpha Version 3

Posted on November 11, 2024 in Divi Resources

The Divi 5 Public Alpha is available for testing. As we progress towards the final release, we’ll update Divi 5 every two weeks, appearing as a standard update in your WordPress dashboard. If you use Divi 5, you’ll notice an update notification for Public Alpha Version 3 today. Thanks...

View Full Post

10 Comments

  1. Hi,
    This is what i’ve got when i try to import the template:
    “This file should not be imported in this context.”

  2. It will be more useful to provide the FULL code, instead of peace meals.

  3. In what place is the JSON file uploaded? I’ve tried to import into Divi Library and it says “This file should not be imported in this context.”

    • It’s a layout for a custom header in the Theme Builder so the JSON file should be uploaded using the import/export tool in Theme Builder. Check this screenshot: https://prnt.sc/Q3TT_hf755nV

  4. Useful tutorial… but can we please take a serious look at improving the way you write and present these tutorials?

    I know it’s nice to know how you got the EXACT result you had but we came here for the CSS / JS snippets that were the last little segment of the tutorial. Skip over all the idle fluff about what margins, box shadows, font sizes etc that you’ve arbitrarily included – that’s all totally irrelevent to the tutorial itself and will also be irrelevant to the website’s we, the audience, are building. All it actually achieves is wasting both the reader’s and the author’s time.

  5. I’ve got to say, I added a Hamburger Menu to a desktop site, but what I did seemed a lot simpler than this. I seem to recall I just messed with the CSS around the various viewport triggers (pixel breakpoints) to get this set up, so if you’re so inclined, you might want to try that instead of all of this extra code/steps.

    • Hi Steve, i agree with you but I don’t play as well as you with the CSS… Could you help me ? Emmanuel

  6. Really great! Question: would it be possible to also use different menu types for this, e.g. fullscreen menu, and then also have the hamburger icon on the left and logo on the right?

    • Nice One! Please make these headers (and footers) available from within the Visual Builder/Theme Builder. It’s a hassle to browse around years of blog posts to get an overview of the different templates.

  7. Great ! That’s all I was missing!

Leave A Reply

Comments are reviewed and must adhere to our comments policy.

Join To Download Today