Slide-in Sidebar Section in the Divi theme

Learn how to create Smooth Slide-in Sidebar Section with custom CSS and jQuery!

A sidebar section is a great and useful tool but it can also distract the user from the main content of your page. Especially when it takes a lot of the website’s space.

That’s why in this tutorial, I will show you how to use Divi Builder to create a slide-in sidebar that will show up only after you click on the button. 

We are going to use the custom CSS and some jQuery code to achieve that. Watch my step-by-step walkthrough video and copy the code we used below!

If you’re our subscriber feel free to download the JSON file!

Free Resources for Divi Lovers

Join our newsletter to get the good stuff!

We’ll provide you with updates on new tutorials, webdesign assets and special offers. Get top quality Divi goodies straight into your inbox! Read our Privacy Policy to learn how we manage and protect your submitted information.

Sign up to download

Get access to this layout and all the free resources made exclusively for our subscribers!

Already subscribed?

Fill the signup form and if you’re on the list it’ll get you straight to the download page! 

Can’t see the form? Click here

Step 1. Add a section in the Divi Builder 

In the Advanced tab of the section setting, we need to change the position of the sidebar section to “Fixed”. We also need to include a custom CSS class. The CSS class used in the demo example is called dl-slide-sidebar.

The max-width of the section is set to 300px and if there is a lot of content, make sure to change the horizontal overflow value to “scroll” (in the Advanced tab of the section settings).

Step 2. Add the Close Button inside the Sidebar

To create an X close button we used the Blurb module added in the sidebar section. The module does not have a title, nor any content. We enabled the icon and changed the width, height, and the icon size to 50px. To make sure the sidebar section slides out upon clicking on the Blurb – we’ve added a custom CSS class of dl-close so that we can target this element in our JavaScript code.

Step 3. Add the Button trigger

We are using a standard Divi Button with a custom CSS class of dl-btn-toggle. The button text will be changed dynamically, but on the page load it is set to “Open”.

Add the CSS Styles!

Here is the CSS code we used to hide the sidebar only if not in the Visual Builder and to show it when it gets a new CSS class of is-opened. The “translateX” value needs to match the section width. The last bit adds a hand cursor to the Blurb module: 

body:not(.et-fb) .dl-slide-sidebar {
body:not(.et-fb) {
.dl-slide-sidebar.has-transition {
.dl-close {

Finally, the jQuery magic!

This is the final jQuery code. To understand what it does – please watch the video 😉

jQuery(document).ready(function($) {
	var dl_ButtonToggle = $('.dl-btn-toggle');
  	var dl_SlideSidebar = $('.dl-slide-sidebar');
  	function dl_SidebarCheck() {
      if (dl_ButtonToggle.hasClass('is-opened')) {
      else {
    } {
  	$('.dl-close').click(function() {

What do you think?

Feel free to use it on your website and do not hesitate to show us the final result! We are eager to see the effects of your work!

We always appreciate your feedback, so please share your opinion with us in the comments! 


Have you seen our

Divi child themes?

Divi Toolbox plugin?

We offer a great selection of high-quality Divi products to speed up your work. Feel free to use a coupon code IREADBLOG at the checkout to get a 10% discount!


  1. Joel

    Great tutorial! I would like to do exactly this, but I would like push the page to the main elements on the page to the left and resize the items (like you are making your browser window smaller). I hope I’m explaining that correctly.

    • Joel

      For example, when you click on the Open button, the menu would come out and shift all of the page elements to the left.

  2. Stoan

    Hi Ania

    Love your work, thanks for this.
    Do you think it would be possible to slide it out after a certain time using a conditional?
    Say 5 seconds after the page has loaded it slides out, it’s much less intrusive than a popup.
    For mobile it would probably need a different way.

    • Ania Romańska

      Thank you, Stoan 🙂
      You might want to look at this tutorial and combain the two methods together..

  3. Murray Russell

    Hi Ania. Just downloaded and implemented the code from your freebie for which many thanks. It works so I can check where I went wrong.

  4. Murray Russell

    This is exactly what I want and your explanations are great however while having checked multiple times that I have followed you and have copied the code directly from this site, clicking the button gives
    “Uncaught ReferenceError: dl_Buttontoggle is not defined
    at dl_SidebarCheck ((index):111)”
    Any assistance greatly appreciated thank you.

  5. Abhinav

    Ania please please please share how can we turn display: none before click and return to regular default display value using your code. Could you please share a snippet i can add to the above code.

    Thanks a bunch in advance. hope you actually answer. Awaiting your reply.

    • Abhinav bhalla

      what i mean to say is display: none; before any click or trigger and then return to default display value after click.

      Then we also need it to revert to display: none; when the close icon is clicked.

      Awaiting your reply.

      Your tuts is very good but then i find this to be the only caveat in your code.

      • Ania Romańska

        I’m sorry, but I do not understand what it is you are trying to achieve. If you click the close icon, it closes the panel – not sure what do you mean by “need it to revert display:none”.

  6. Jacob Eggebeen

    How can we have the sidebar close if anywhere outside of it is clicked?

  7. Ania

    Hi! I would like to make Slide-in Sidebar Section fixed on the uper part of my page. I did it but I have issue when it opens because it covers my menu. Could you help me? What extra code I should use?

  8. San

    Hello i arrive to the jquerry, then i dont know how to continue.
    Can you send me the download link?

  9. Jyoti


    How can I display hamburger icon instead of ‘Open’ and ‘Close’

    Please help.


  10. Hurri

    Ania, I love your tutorial style, its simple easy to follow and as always very useful!
    Thank you so much for making the effort to give us these free snippets!

  11. Aiman

    Perfecto! i learn jQuery but since then i don’t know how to use in Divi. LOL

    So i easily understand your step by step guide throughout this videos.


Submit a Comment

Your email address will not be published.

I want to stay in touch! I’d like to receive special offers and tutorials from Divi Lover. Sign me up for awesome content! I know that I can unsubscribe at any time.

Enjoing our content?

You might find this interesting…

License Details


Single Site

A regular license allows an item to be used in one project for either personal or commercial use by you or on behalf of a client. The item cannot be offered for resell either on its own or as a part of a project. Distribution of source files is not permitted.


Unlimited Sites

An extended license allows an item to be used in unlimited projects for either personal or commercial use. The item cannot be offered for resell either on its own or as a part of a project. Distribution of source files is not permitted.


Each license is a one-time payment. There are no annual fees. You get lifetime access to product updates. Support is provided for 6 months from the date of purchase.

Server Requirements


  • PHP 7.2 or later
  • upload_max_filesize (256M)
  • max_input_time (300)
  • memory_limit (256M)
  • max_execution_time (300)
  • post_max_size (512M)


  • php-xml or/and php-dom
  • XMLReader
  • PHP CURL module


  • allow_url_fopen