Skip to content
Content Blocks docsv0.8.0Website

Docs / Components

<content-accordion>

A button that shows and hides the content below it, such as an answer in a list of questions.

Import it on its own, for a bundler
import '@content-blocks/js/components/content-accordion';

Examples

Questions and answers

Each question is a button that shows and hides its answer.

Open on its own
When will the hero return?

When the wolf breaks his chain and the horn sounds from the bridge.

Can Ragnarök be stopped?

Only if the hero reaches the bridge before the giants do.

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
The slots of <content-accordion>
SlotWhat 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.

AttributeTypeDefaultDescription
animation-endString'animation-end'The ending animation class in case you want to control content styling.
animation-startString'animation-start'The starting animation class in case you want to control content styling.
animation-timeNumber0The amount of time in milliseconds to run the closing animation, before the class is removed
classesresponsiveString–Classes to add to the component. Use pipes for different classes per breakpoint, by name or in order: classes="stacked|laptop=side-by-side".
openresponsiveBoolean'false'Not documented yet
paddingresponsiveString–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-classString''The class to be applied to the trigger button element.