Bootstrap Accordion Shortcode

Shortcode to build vertically accordions, the FAQs is the most common use case.

Syntax

1{{< bs/accordion >}}

Parameters

data

PositionNameTypeRequiredDefaultSinceExample
#0datastring---

The data filename without extension.

flush

PositionNameTypeRequiredDefaultSinceExample
-flushboolean-false--

When true, remove some borders and rounded corners to render accordions edge-to-edge with their parent container.

alwaysOpen

PositionNameTypeRequiredDefaultSinceExample
-alwaysOpenboolean-false--

When true, make accordion items stay open when another item is opened.

Data Files Mapping

PathData
data/faq.yamlfaq
data/faq.tomlfaq
data/faq.jsonfaq
data/sub/faq.yamlsub.faq
data/sub/faq.tomlsub.faq
data/sub/faq.jsonsub.faq

Data Item Properties

title

NameContextTypeRequiredDefaultSinceExample
title-string----

The title of accordion item.

content

NameContextTypeRequiredDefaultSinceExample
content-string----

The content of accordion item, Markdown is support.

weight

NameContextTypeRequiredDefaultSinceExample
weight-string----

The weight of accordion item, the lower weight gets higher priority.

show

NameContextTypeRequiredDefaultSinceExample
show-string----

The first item’s content will be shown by default, but you can change it via this property.

Data File Example

data/accordion/faq.yaml
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-yaml" data-lang="yaml"><span class="line"><span class="ln">1</span><span class="cl">- <span class="nt">title</span><span class="p">:</span><span class="w"> </span><span class="l">Q1</span><span class="w">

2 content: A1, … 3- title: Q2 4 content: A2, …

Examples

Default Accordion Example

Source
1{{< bs/accordion "accordion.faq" >}}
Result

A1, …

A2, …

Flush Accordion Example

Source
1{{< bs/accordion data="accordion.faq" flush=true >}}
Result

A1, …

A2, …

Flush Accordion Example with alwaysOpen Enabled

Source
1{{< bs/accordion data="accordion.faq" flush=true alwaysOpen=true >}}
Result

A1, …

A2, …