Divi Tutorial – Styling the toggle icons

Divi Tutorial – Styling the toggle icons

Edited on May 27th 2022

Toggles and accordions. First, read up on when they’re useful for UI, and when they are not.

So for this tutorial, let’s assume using them are helpful for the page.

Somehow, they get real boring quickly, and they’re not always the coolest.

Check out the toggle on the demo site. The icon is different, plus check out the sweet animation on the toggles. (The accordions are slightly different)

The snippet

Here, copy this and paste it somewhere that custom code is welcomed.

.et_pb_toggle_open .et_pb_toggle_title:before {
  content: "\4c";
  color: black;
  font-size: 36px;
  -webkit-transition: all 0.5s ease-in-out;
  -moz-transition: all 0.5s ease-in-out;
  -o-transition: all 0.5s ease-in-out;
  -ms-transition: all 0.5s ease-in-out;
  transition: all 0.5s ease-in-out;
  -webkit-transform: rotate(45deg);
  -moz-transform: rotate(45deg);
  -o-transform: rotate(45deg);
  -ms-transform: rotate(45deg);
  transform: rotate(45deg);
}
 
.et_pb_toggle_close .et_pb_toggle_title:before {
  color: black;
  font-size: 36px;
  content: "\4c";
  -webkit-transition: all 0.5s ease-in-out;
  -moz-transition: all 0.5s ease-in-out;
  -o-transition: all 0.5s ease-in-out;
  -ms-transition: all 0.5s ease-in-out;
  transition: all 0.5s ease-in-out;
  -webkit-transform: rotate(0deg);
  -moz-transform: rotate(0deg);
  -o-transform: rotate(0deg);
  -ms-transform: rotate(0deg);
  transform: rotate(0deg);
}

Some explanations

What we’re using here is a pseudo element. Simply put, it’s something you attach before or after an element to make it display something extra. It’s really useful in many ways of styling things, and here, the toggle gets some.

One styles the open toggle, the other one styles the closed toggle.

  • color: black; -> The color of the icon
  • font-size: 36px; -> It’s gotta be a certain size, otherwise it’s too small.
  • content: “\4c”; -> This is based off of the Elegant Themes Iconset. You can change this if you want. To learn how to add more icons, check out an example of the method here.
  • transition: all 0.5s ease-in-out; -> a bunch of transitions with vendor prefixes. You can change the 0.5s from half a sec to something else if you want.
  • transform: rotate(45deg); -> a bunch of transforms with vendor prefixes. You can probably see that this rotates the icon by 45 degrees.

So yeah, change the values to get what you want. Have fun!

[sc name=”learn css”]

[sc name=”podcast”]

Get Breakdance

Breakdance is, in my opinion, the best page/site builder on the market, which is why all my tutorials use Breakdance. It's also why I have an affiliate link. You don't pay extra, but I get a little commission, so it helps support the site. Thanks!

Get ACF Pro

Another essential plugin for site building. This isn't an affiliate link, it's just for convenience.

Get WP Codebox Pro

If you'd like an easier to use, and more advanced code management plugin (instead of just editing and making files yourself) then WP codebox pro is for you. Adding php, js, and even SCSS. Pretty nice! Affiliate link below.

Blank Plugin

Sort of blank. It's made to be easy to use with the tutorials. Download and edit any way you see fit.
  1. Hi there!

    I really like the toggle icon when you click it it turns out to X., but I can’t add that on the website of my client. Can you help me please?

  2. Hi there, I send a message to the link you’ve posted. I’m happy that you reply on my post.

Leave a Reply

Your email address will not be published. Required fields are marked *

New tutorials

Auto-updating Year in Footer
Designing Beyond the Brief
Disable Gutenberg Editor on some ACF pages
ACF flexible content fields in Breakdance 2.4

Got a question? ask!

If you have any question about the content on this page, feel free to send me an email by clicking the button below.

newsletter? sign up!

Sign up to the newsletter for updates on tutorials, news, and offers.

Join the cypher!

An awesome membership program for Breakdance Builder users coupled with an inclusive, friendly community.

Got a question?

If you have a question about something on this page, send me an email, and hopefully I can answer, and we can solve it!