<content-accordion>
A button that shows and hides the content below it, such as an answer in a list of questions.
import '@content-blocks/js/components/content-accordion';Examples
Questions and answers
Each question is a button that shows and hides its answer.
When the wolf breaks his chain and the horn sounds from the bridge.
Only if the hero reaches the bridge before the giants do.
<content-accordion>
<span slot="trigger">When will the hero return?</span>
<p>When the wolf breaks his chain and the horn sounds from the bridge.</p>
</content-accordion>
<content-accordion>
<span slot="trigger">Can Ragnarök be stopped?</span>
<p>Only if the hero reaches the bridge before the giants do.</p>
</content-accordion>content-accordion > button {
padding: 0.9rem 0;
font-weight: 600;
border-top: 1px solid #cbd5e1;
}// $ npm install @content-blocks/js
import '@content-blocks/js/components/content-accordion';<script type="module"
src="https://cdn.jsdelivr.net/npm/@content-blocks/js/dist/content-blocks/content-blocks.esm.js"></script>Anatomy
Content goes into the component's slots, chosen with the slot attribute on each child.
flowchart LR root["#lt;content-accordion#gt;"]:::component root --> s0["<b>no slot (default)</b><br/>Default slot, same as content slot."] root --> s1["<b>slot=#quot;content#quot;</b><br/>This slot will usually serve a content button."] root --> s2["<b>slot=#quot;trigger#quot;</b><br/>This is the contents of the button that will expand / hide the accord…"] classDef component fill:#141413,color:#faf9f5,stroke:#141413
| Slot | What goes in it |
|---|---|
(default) | Default slot, same as content slot. |
slot="content" | This slot will usually serve a content button. |
slot="trigger" | This is the contents of the button that will expand / hide the accordion. |
Properties
Set them as attributes. Those marked responsive take a value per breakpoint, separated by pipes and named or in order: 1|tablet=2 or 1|2. Seeresponsive values.
| Attribute | Type | Default | Description |
|---|---|---|---|
animation-end | String | 'animation-end' | The ending animation class in case you want to control content styling. |
animation-start | String | 'animation-start' | The starting animation class in case you want to control content styling. |
animation-time | Number | 0 | The amount of time in milliseconds to run the closing animation, before the class is removed |
classesresponsive | String | – | Classes to add to the component. Use pipes for different classes per breakpoint, by name or in order: classes="stacked|laptop=side-by-side". |
openresponsive | Boolean | 'false' | Not documented yet |
paddingresponsive | String | – | Padding around the component, written as CSS padding. Use pipes for different padding per breakpoint, by name or in order: padding="1rem|tablet=2rem 4rem" or padding="1rem|2rem 4rem|3rem 5rem 4rem". |
trigger-class | String | '' | The class to be applied to the trigger button element. |
