How to Customize Genesis Blocks Accordion Styles

Customizing Genesis Blocks Accordion

Do you like Genesis Blocks collection but you will like to have more control over the accordion block design? In this tutorial you will learn how you can customize it with few lines of CSS.

UPDATE: If you prefer to use the WordPress Site Editor native blocks to create an accordion, take a look at this tutorial where we show you how to customize the Details Block with a bit of CSS.

Nowadays, in addition to the native blocks of WordPress, the block library that we use mainly in our WordPress projects is Genesis Blocks (formerly Atomic Blocks).

We use it for those additional elements that we may need, such as containers, advanced columns or the accordions. The later is very useful for the common layout of FAQ or in those pages that have a lot of content and it is more tidy and convenient to group them in small sections.

However, the styles that come by default for the block accordion are quite limited and do not always fit well with the web design.

GB Accordion styles

Although it allows you to customize typography, colors and sizes, you cannot change the style of the arrow that appears to expand the element or its location, and that restricts a lot and makes this block very similar on all pages.

To avoid this, you can use some CSS classes, some very intuitive and others not so much, to customize it.

The HTML structure of the block is quite simple:

GB Accordion styles
  • gb-block-accordion: the whole block
  • details: includes title and content
  • gb-accordion-title: the title part
  • gb-accordion-text: the content that appears when it is displayed.

Adding or modifying styles for these elements is simple, but nowhere in the code or in the inspector does the arrow icon appear to the left of the title, and modifying it does not seem so easy.

GB accordion adds the arrow using a native element (-webkit-details-marker) of the browser we are using, and to access it we must use .gb-block-accordion .gb-accordion-title::-webkit-details-marker.

The easiest way is to hide it directly and then add, with :after or :before, according to whether we want our own icon to appear to the right or left of the title.

.gb-block-accordion .gb-accordion-title::-webkit-details-marker {
    display: none;

We added a custom arrow icon to the right:

.gb-block-accordion details .gb-accordion-title:after{
    content: url("images/chevron-down.svg");
    position: absolute;
    right: 2.4rem;
    top: 50%; 
    line-height: 1; 

To modify the icon when displaying the element, or any other style that you want to be shown differently if it is open or closed, you can use the open attribute that GB adds to details when the element is open:

Example: you can put the title in bold when it is displayed:

.gb-block-accordion details[open] .gb-accordion-title {
	font-weight: 600;

Or modify the icon:

.gb-block-accordion details[open] .gb-accordion-title:after{
	content: url("images/close-circle-outline.svg");

You could also, instead of changing the image, make a CSS transformation if it is for example an arrow, simply rotate it down transform: translateY(-50%) rotate(-45deg); or change size, color, etc… any property that can be accessed from CSS.

In this way with a few lines of CSS you can replace the standard accordion that we saw at the beginning, by this:

GB Accordion styles

Or any variation you can think of.

As you see, knowing this you can get much more out of this Genesis Blocks block and avoid having to use different block libraries just for one element you don’t like.

REMEMBER: If you prefer to use the WordPress Site Editor native blocks to create an accordion, take a look at this tutorial where we show you how to customize the Details Block with a bit of CSS.

We hope you find the tutorial useful. If you have any question or suggestion just let us know in the comments

Filed under


Nahuai Badiola Avatar


4 responses

  1. Nick Tyrrell Avatar
    Nick Tyrrell

    I wish to add colours to the background of the accordion block title bar for various sections of my site.
    I’m struggling to find a CSS which works with multiple blocks – I can get them all to be the same colour but not have individual colours per block

    – background for the title bar only.

    1. esther sola Avatar
      esther sola

      Hi Nick,

      You can add an additional CSS class in the block (or group) settings and create a specific style for it, something like this: .gb-accordion-title {
      background: #ffc7c7;

      Where “accordion-one” is the class added in the block.


      1. Nick Tyrrell Avatar
        Nick Tyrrell

        Apologies Esther, I’ve only just returned to this and have seen your answer from earlier.
        Many thanks.

        1. esther sola Avatar
          esther sola

          Hi Nick! Thanks for your comment.


Leave a Reply

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