We do have many requests for accordions, there are many problems with it:
- Sparkle’s layout engine doesn’t work as well as it should with content expanding in the live page
- Accordions are the lazy designer solution to doing the proper work, they feel legit user interface because they’re so widespread in coding tools (spoiler, they’re not)
- Accordions have annoying UX issues particularly on devices with small screens, due to how stuff moves on the page
Something most people don’t realize is that while the straightforward use of a Sparkle element is straightforward for us to build, edge case are 10x the work. We try to support edge cases as much as possible, because they make Sparkle feel freeform and supporting creativity. It doesn’t feel like there’s a limit to what you can do (within the declared constraints). I feel the accordions present a huge amount of complexity and edge cases to support, while having the faults I described.
About the code you want to use, the same previous answer applies: