Two accessible examples: a native details element and a custom button-controlled widget. Both use a container with the class "details" for the controlled content. Each widget is wrapped in an element with the class "example".
Use Enter or Space to toggle the disclosure. The content container below has class="details".
When you expand this section, you'll see a short list of items included in the package:
Native <details> and <summary> elements provide built-in keyboard support and are widely supported by assistive technologies.
This custom version uses a button with aria-expanded and aria-controls. The controlled content is a div with class="details".