Halloween Sale 15% off Ends in See the plans
SCSS

Accordion Style for the Details Block (SCSS)

Styles the core Details block as a polished accordion with borders, a rotating plus icon and comfortable spacing, so FAQs look finished without a plugin.

Don’t have WPIDE yet? Install it on your site

Code

$border: rgba(0, 0, 0, 0.15);
$accent: #2271b1;

.wp-block-details {
    margin: 0;
    padding: 0;
    border: 1px solid $border;

    & + .wp-block-details {
        border-top: 0;
    }

    summary {
        position: relative;
        padding: 1em 3em 1em 1.25em;
        font-weight: 600;
        list-style: none;
        cursor: pointer;

        &::-webkit-details-marker {
            display: none;
        }

        &::after {
            content: "+";
            position: absolute;
            top: 50%;
            right: 1.25em;
            font-size: 1.4em;
            line-height: 1;
            transform: translateY(-50%);
            transition: transform 0.2s ease;
        }

        &:focus-visible {
            outline: 2px solid $accent;
            outline-offset: -2px;
        }
    }

    &[open] summary::after {
        transform: translateY(-50%) rotate(45deg);
    }

    > :not(summary) {
        margin: 0;
        padding: 0 1.25em 1em;
    }
}

Notes

Consecutive Details blocks join into one accordion list.

How to add this snippet

  1. Install WPIDE on your WordPress site (it is free) and open Code Snippets.
  2. Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
  3. It is added inactive: review the code and settings, then switch it on.

Have a snippet worth sharing?

Publish it to the library from WPIDE or right here. Sign in with any WordPress site that runs WPIDE, free or Pro. Public snippets are reviewed by the WPIDE team before they appear.

Which site should get this snippet?

Enter the address of your WordPress site. WPIDE opens there in a new tab with the snippet ready to review and save.

Remembered in this browser only, so you are asked once.

Report this snippet

Tell the WPIDE team what is wrong: broken code, something harmful, spam or copied work.