Expand/Collapse Widget Showcase
Basic FAQ Accordion
What is an expand/collapse widget?
An expand/collapse widget lets you toggle the visibility of content sections. It keeps interfaces tidy by showing only what users need at a given moment.
Can the widget start opened?
Yes! Add the open attribute to the container, and it will render in the expanded state by default. Users can still collapse it afterward.
Is it accessible?
Using the native <details> and <summary> elements ensures keyboard and screen reader support without extra scripting.
Tip: Use concise summary labels so visitors instantly understand what each panel contains.
Controlled Sections with Actions
Design Guidelines
Maintain consistent spacing and typography for summaries. Provide visual feedback when panels expand so users recognize the change.
Code Snippet
Each widget is wrapped inside a parent with the example class, while the collapsible container itself carries the details class.
Accessibility Checklist
- Ensure the summary text is descriptive.
- Use logical heading structure around widgets.
- Keep keyboard focus states visible.