Expand/Collapse Widgets Demo

Widget 1: Basic Information

This is a standard expand/collapse widget using native HTML `<details>` and `<summary>` tags.

Click here for more details about this section

This content will be shown or hidden when the summary is clicked.

  • Item A
  • Item B
  • Item C

It can contain any HTML elements you wish.

Widget 2: Frequently Asked Questions

What is an expand/collapse widget?

An expand/collapse widget allows users to reveal or hide sections of content on a webpage. This helps in managing screen real estate and presenting information efficiently.

How does this example work?

This example utilizes the native HTML <details> and <summary> elements. No JavaScript is required for the core functionality, making it very performant and accessible by default.

The <summary> element acts as the visible title, and when clicked, it toggles the visibility of the content following it within the <details> tag.

Can a widget be open by default?

Yes, by adding the open attribute to the <details> tag, like this example, the widget will be expanded when the page loads.

Widget 3: Nested Content

Expand to see a nested example

This is the outer content.

Click for inner content

This content is nested inside another expand/collapse widget!

Nesting widgets can help organize complex information hierarchies.

More outer content after the nested widget.