Skip to content

Collapsible Examples

The examples below assume that you have imported the component and set up the theme.

Basic

Toggle unstyled content with a button. A <button> in the trigger slot toggles the content.

Workspace details

The collapsible animates the space this panel takes, and the button in the trigger slot toggles it.

--opened
<div class="collapsible-basic">
<sv-collapsible>
<button type="button" class="btn" slot="trigger">Show details</button>
<div class="details">
<h2>Workspace details</h2>
<p>
The collapsible animates the space this panel takes, and the button in the trigger slot
toggles it.
</p>
</div>
</sv-collapsible>
</div>
<style>
.collapsible-basic {
inline-size: min(28rem, 100%);
margin-inline: auto;
.btn {
display: block;
margin-inline: auto;
}
.details {
padding: 1em;
margin-block-start: 0.5em;
color: var(--sv-gray-2);
background: var(--sv-gray-7);
border-radius: var(--sv-bdr-rad-md);
h2 {
margin-block: 0 0.5em;
font-size: 1.1rem;
}
p {
margin: 0;
}
}
}
</style>