DEV Community

Discussion on: Accordion tailwindCss

Collapse
 
jsn1nj4 profile image
Elliot Derhay • Edited

What about using CSS directly to toggle the display of the accordion items?

So maybe something like this:

input[type="checkbox"]:checked + div {
  /* styles */
}

MDN: Adjacent Sibling Combinator

There are also tricks like wrapping the entire contents of an accordion item in the label that's related to the checkbox, and then doing something like this instead:

input[type="checkbox"]:checked > div {
  /* styles */
}
Collapse
 
giandodev profile image
GiandoDev

Hey cool thank you 🙏

Collapse
 
jsn1nj4 profile image
Elliot Derhay

No problem! Glad to help.