List categories in a accordion

Anyone know how to list categories in an accordion?
Not much documentation about the list categories action so struggling a bit with getting it to work correct.
Using a bootstrap 5 accordion and i want to show the main categories in the head of the accordion and the sub categories in the accordion body.