Expand / Collapse Widget Examples

Each widget below demonstrates an accessible expand/collapse pattern. Controlled content containers use the details class.

Simple Toggle

Click the button to expand/collapse

Initially open

This one starts open

Content is visible by default. The JavaScript will set an inline max-height to allow a smooth transition if the user collapses it.

Tip: You can include any markup inside a details container — text, images, forms, etc.

Long content (demo of animation)

The container expands to fit content height