FAQ Accordion Styles (SCSS)
Styles collapsible FAQ items (from the FAQ list and ACF FAQ shortcodes, or any Details block) with dividers, a plus/minus marker and a visible keyboard focus ring.
Opens WPIDE on
Code
$divider: color-mix(in srgb, currentColor 15%, transparent);
$focus: #2271b1;
.faq-item,
.acf-faq-item,
.wp-block-details {
border-bottom: 1px solid $divider;
summary {
display: flex;
justify-content: space-between;
align-items: center;
gap: 1rem;
padding: 1rem 0;
font-weight: 600;
cursor: pointer;
list-style: none;
&::-webkit-details-marker {
display: none;
}
&::after {
content: "+";
flex-shrink: 0;
font-size: 1.4em;
line-height: 1;
}
&:focus-visible {
outline: 2px solid $focus;
outline-offset: 2px;
}
}
&[open] summary::after {
content: "\2212";
}
> :not(summary) {
padding-bottom: 1rem;
}
}
Notes
Targets .faq-item, .acf-faq-item and the Details block.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.