Snippets Accordion

Bootstrap 5 Accordion Image Gallery

An expanding accordion image gallery where the active photo grows to reveal its caption, working by hover, tap or keyboard focus.

Bootstrap 5 No jQuery Mar 2020 3.5K views

<section class="wdw-stage">
  <div class="container w-100" style="max-width:1100px">
    <div class="d-flex flex-wrap align-items-end justify-content-between gap-2 mb-4">
      <div><span class="wdw-eyebrow">Gallery</span><h1 class="wdw-heading h2 mt-1 mb-0">Colour studies</h1></div>
      <p class="wdw-muted mb-0 small">Hover, tap or focus a panel to expand it.</p>
    </div>
    <div class="ag-gallery" id="agGallery" role="group" aria-label="Image gallery">
        <button type="button" class="ag-item is-open" aria-expanded="true" style="--img:url('https://images.unsplash.com/photo-1499198116522-4a6235013d63?auto=format&fit=crop&w=900&q=75')">
          <span class="ag-caption"><span class="ag-num">01</span><strong class="d-block">Studio stool</strong><span class="small">Oak and rattan, hand finished</span></span>
        </button>
        <button type="button" class="ag-item" aria-expanded="false" style="--img:url('https://images.unsplash.com/photo-1492760864391-753aaae87234?auto=format&fit=crop&w=900&q=75')">
          <span class="ag-caption"><span class="ag-num">02</span><strong class="d-block">Spiral stair</strong><span class="small">Warm curves, bold colour</span></span>
        </button>
        <button type="button" class="ag-item" aria-expanded="false" style="--img:url('https://images.unsplash.com/photo-1503631285924-e1544dce8b28?auto=format&fit=crop&w=900&q=75')">
          <span class="ag-caption"><span class="ag-num">03</span><strong class="d-block">Berry smoothie</strong><span class="small">Still life in red</span></span>
        </button>
        <button type="button" class="ag-item" aria-expanded="false" style="--img:url('https://images.unsplash.com/photo-1510425463958-dcced28da480?auto=format&fit=crop&w=900&q=75')">
          <span class="ag-caption"><span class="ag-num">04</span><strong class="d-block">Floating banana</strong><span class="small">Playful product shot</span></span>
        </button>
        <button type="button" class="ag-item" aria-expanded="false" style="--img:url('https://images.unsplash.com/photo-1503602642458-232111445657?auto=format&fit=crop&w=900&q=75')">
          <span class="ag-caption"><span class="ag-num">05</span><strong class="d-block">Bar stool</strong><span class="small">Pale ash on soft blue</span></span>
        </button>
        </div>
  </div>
</section>

Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.