Skip to main content

Collapsible
New

Collapsible is a disclosure component used to reveal additional content. It should contain a heading, followed by any additional content that is revealed on click.

Examples

Open in new window
<duet-collapsible heading="Click to open details">
Lorem ipsum dolor sit, amet consectetur adipisicing elit.
Aperiam impedit, possimus minima repudiandae.
</duet-collapsible>

<script>
// Select the above component
var collapsible = document.querySelector("duet-collapsible")

// Listen for toggle events
collapsible.addEventListener("duetToggle", function(e) {
console.log("open", e.target.open)
})
</script>
Open in new window
<duet-collapsible heading="Click to open details">
Lorem ipsum dolor sit, amet consectetur adipisicing elit.
Aperiam impedit, possimus minima repudiandae.
</duet-collapsible>
<duet-divider margin="small"></duet-divider>
<duet-collapsible heading="Click to open">
Lorem ipsum dolor sit, amet consectetur adipisicing elit.
</duet-collapsible>
<duet-divider margin="small"></duet-divider>
<duet-collapsible heading="Click to">
Lorem ipsum dolor sit, amet consectetur adipisicing elit.
</duet-collapsible>
<duet-divider margin="small"></duet-divider>
<duet-collapsible heading="Click to open">
Lorem ipsum dolor sit, amet consectetur adipisicing elit.
</duet-collapsible>
Open in new window
<duet-collapsible heading="Click to open details" open>
Lorem ipsum dolor sit, amet consectetur adipisicing elit.
</duet-collapsible>

Properties #

Property Attribute Description Type Default
heading heading The content for the collapsible heading. string ""
margin margin Controls the margin of the component. "auto" | "none" "auto"
open open Is the component expanded or collapsed. boolean false
theme theme Theme of the definition list. "" | "default" | "turva" ""

Events #

Event Description Type
duetToggle Event emitted when opened/closed CustomEvent<{ component: "duet-collapsible"; originalEvent: MouseEvent | KeyboardEvent; }>

Methods #

setFocus() => Promise<void> #

Sets focus on the specified duet-collapsible. Use this method instead of the global
collapsible.focus().

Returns #

Type: Promise<void>


Usage #

This section includes guidelines for designers and developers about the usage of this component in different contexts.

When to use #

  • To hide information with lower priority.
  • To put long sentences of information under a section that user can expand or collapse.
  • In comparison tables to reveal additional information about insurance coverage.

When not to use #

  • For mandatory information or actions.
  • For hiding form elements.

Accessibility #

This component has been validated to meet the WCAG 2.1 AA accessibility guidelines. You can find additional information regarding accessibility of this component below.


Integration

For integration, event and theming guidelines, please see Using Components. This documentation explains how to implement and use Duet’s components across different technologies like Angular, React or Vanilla JavaScript.



Tutorials

Follow these practical tutorials to learn how to build simple page layouts using Duet’s CSS Framework, Web Components and other features:

Tutorials

Abstract

Tutorials

Building Layouts

Tutorials

Using CLI Tools

Tutorials

Creating Custom Patterns

Tutorials

Server Side Rendering

Tutorials

Sharing Prototypes

Tutorials

Usage With Markdown

Tutorials

VS Code

Tutorials

Zeplin


Troubleshooting

If you experience any issues while using a component, please head over to the Support page for more guidelines and help.