The Modern CSS Grid Solution to Auto-Height Transitions
For over two decades, web developers struggled to animate elements from height: 0 to height: auto in pure CSS. Developers resorted to animating max-height (which creates artificial timing delays) or computing element.scrollHeight in JavaScript (which forces synchronous CPU layout reflows).
How grid-template-rows: 0fr -> 1fr Works
Modern browsers support transitioning grid track sizes. By placing the expandable content inside a container with display: grid and grid-template-rows: 0fr, the content collapses completely. When the .open class is applied, transitioning to 1fr smoothly reveals the content without triggering layout thrashing:
.faq-accordion-widget-content-wrapper {
display: grid;
grid-template-rows: 0fr;
transition: grid-template-rows 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}
.faq-accordion-widget-item.open .faq-accordion-widget-content-wrapper {
grid-template-rows: 1fr;
}
.faq-accordion-widget-content-inner {
overflow: hidden;
}
ARIA Accessibility Standards
Each accordion trigger button includes aria-expanded="false" (toggled to true when open) and proper heading relationships so screen reader users can navigate through topics effortlessly.