Snippets Accordion

Bootstrap 5 Image Accordion with Hover Expand

An image accordion where four photo panels expand on hover, tap or arrow keys to reveal a caption, with an optional colour tint on the collapsed panels.

Bootstrap 5 No jQuery Mar 2020 2.2K views

<section class="wdw-stage">
  <div class="container" style="max-width:1080px">
    <div class="d-flex flex-column flex-md-row align-items-md-end justify-content-between gap-3 mb-4">
      <div>
        <span class="wdw-eyebrow mb-2">Photo journal</span>
        <h1 class="wdw-heading h2 mb-0">Four places worth the walk</h1>
      </div>
    </div>
    <div class="img-acc tinted" id="imgAcc" role="group" aria-label="Photo collections">
      <button type="button" class="img-acc-item is-active" aria-expanded="true">
        <img src="https://images.unsplash.com/photo-1470071459604-3b5ec3a7fe05?w=900&q=80" alt="Misty forest valley at first light" loading="lazy">
        <span class="img-acc-cap"><span class="img-acc-num">01</span><strong>Woodlands</strong><span class="img-acc-sub">Fog between the old pines</span></span>
      </button>
      <button type="button" class="img-acc-item" aria-expanded="false">
        <img src="https://images.unsplash.com/photo-1469474968028-56623f02e42e?w=900&q=80" alt="Hills with a hiker at sunrise" loading="lazy">
        <span class="img-acc-cap"><span class="img-acc-num">02</span><strong>Highlands</strong><span class="img-acc-sub">Slow mornings above the valley floor</span></span>
      </button>
      <button type="button" class="img-acc-item" aria-expanded="false">
        <img src="https://images.unsplash.com/photo-1501785888041-af3ef285b470?w=900&q=80" alt="Lake surrounded by forest" loading="lazy">
        <span class="img-acc-cap"><span class="img-acc-num">03</span><strong>Lakeside</strong><span class="img-acc-sub">Still water and long evenings</span></span>
      </button>
      <button type="button" class="img-acc-item" aria-expanded="false">
        <img src="https://images.unsplash.com/photo-1506744038136-46273834b3fb?w=900&q=80" alt="Mountain river at dusk" loading="lazy">
        <span class="img-acc-cap"><span class="img-acc-num">04</span><strong>Ridgeline</strong><span class="img-acc-sub">Where the trail meets the sky</span></span>
      </button>
    </div>
    <div class="form-check form-switch mt-4">
      <input class="form-check-input" type="checkbox" role="switch" id="accTint" checked>
      <label class="form-check-label wdw-muted" for="accTint">Tint inactive photos</label>
    </div>
  </div>
</section>

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

Free to use in personal and commercial projects under the MIT license.