Details

<wa-details> Stable Since 2.0

Details display a brief summary and expand to reveal additional content. Use them to progressively disclose information, group related FAQs, or hide advanced options.

Click the summary to expand and collapse the details component. You can put any content in here that you want to reveal on demand!

Examples

Link to This Section

Expanded Initially

Link to This Section

Use the open attribute to expand the details initially.

This details component is expanded by default. Users can click the summary to collapse it if they want to hide the content.

Disabled

Link to This Section

Use the disabled attribute to prevent the details from expanding.

This content can't be seen because the details component is disabled. Try removing the disabled attribute to reveal what's inside!

Customizing the Summary Icon

Link to This Section

Use the expand-icon and collapse-icon slots to change the expand and collapse icons, respectively. To disable the animation, override the rotate property on the icon part as shown below.

This example uses custom plus and minus icons for expanding and collapsing. You can use any icon you want to match the look and feel of your app.

Icon Position

Link to This Section

The default position for the expand and collapse icons is at the end of the summary. Set the icon-placement attribute to start to place the icon at the start of the summary.

HTML in Summary

Link to This Section

To use HTML in the summary, use the summary slot. Links and other interactive elements will still retain their behavior:

Some text a link more text You can use the summary slot to put HTML in the summary, including links and other interactive elements. Pretty neat, right?

Right-to-Left Languages

Link to This Section

The details component, including its icon-placement, automatically adapts to right-to-left languages:

Appearance

Link to This Section

Use the appearance attribute to change the element’s visual appearance.

Grouping Details

Link to This Section

Use the name attribute to create accordion-like behavior where only one details element with the same name can be open at a time. This matches the behavior of native <details> elements.

Importing

Link to This Section

If you're using the autoloader or a hosted project, components load on demand — no manual import needed. To cherry-pick a component manually, use one of the following snippets.

CDN npm Self-Hosted React

Import this component directly from the CDN:

import 'https://ka-f.webawesome.com/[email protected]/components/details/details.js';

After installing Web Awesome via npm, import this component:

import '@awesome.me/webawesome/dist/components/details/details.js';

If you're self-hosting Web Awesome, import this component from your server:

import './webawesome/dist/components/details/details.js';

To import this component for React 18 or below, use the following code:

import WaDetails from '@awesome.me/webawesome/dist/react/details/index.js';

Slots

Link to This Section

Learn more about using slots.

Attributes & Properties

Link to This Section

Learn more about attributes and properties.

Methods

Link to This Section

Learn more about methods.

Events

Link to This Section

Learn more about events.

CSS custom properties

Link to This Section

Learn more about CSS custom properties.

Custom States

Link to This Section

Learn more about custom states.

CSS parts

Link to This Section

Learn more about CSS parts.

Dependencies

Link to This Section

This component automatically imports the following elements. Sub-dependencies, if any exist, will also be included in this list.

Need a hand? Report a bug Ask for help
    No results