The community member is using an accordion on their website and wants to change the toggle icon from a "+" to a "-" when a section expands, and back again when it collapses. Other community members suggest using the Radix accordion, which has a state that can be used to display the appropriate icon without needing to write custom JavaScript. They provide example links to demonstrate how this can be achieved by adding two icons and displaying them based on the accordion state.
Hi everyone! I’m using an accordion on my site and I’d like the toggle icon to switch from a “+” to a “–” when a section expands (and back again when it collapses). What’s the easiest way to achieve this—are there any ready-made solutions or a minimal JS snippet I can use without writing tons of custom code? Thanks!