Snippets Table

Bootstrap 5 Table with Sticky Header

A schedule table inside a scrollable card whose column headers stay fixed at the top while the rows scroll, with hover rows and type badges.

Bootstrap 5 No jQuery Jun 2019 2.8K views

<section class="wdw-stage">
  <div class="container" style="max-width:920px">
    <div class="d-flex flex-wrap align-items-end justify-content-between gap-2 mb-3">
      <div><span class="wdw-eyebrow">Timetable</span><h1 class="wdw-heading h3 mb-0">Class schedule</h1></div>
      <span class="wdw-muted small">Scroll the table, the header stays put</span>
    </div>
    <div class="wdw-card overflow-hidden">
      <div class="table-responsive fh-scroll" tabindex="0" role="region" aria-label="Class schedule table">
        <table class="table table-hover align-middle mb-0">
          <thead><tr><th scope="col">Class name</th><th scope="col">Type</th><th scope="col">Hours</th><th scope="col">Trainer</th><th scope="col" class="text-end">Spots</th></tr></thead>
          <tbody><tr><th scope="row" class="fw-semibold">Like a Butterfly</th><td><span class="badge rounded-pill bg-primary-subtle text-primary-emphasis">Boxing</span></td><td class="text-nowrap">9:00 - 11:00 AM</td><td>Aaron Chapman</td><td class="text-end">10</td></tr><tr><th scope="row" class="fw-semibold">Mind & Body</th><td><span class="badge rounded-pill bg-primary-subtle text-primary-emphasis">Yoga</span></td><td class="text-nowrap">8:00 - 9:00 AM</td><td>Adam Stewart</td><td class="text-end">15</td></tr><tr><th scope="row" class="fw-semibold">Crit Cardio</th><td><span class="badge rounded-pill bg-primary-subtle text-primary-emphasis">Gym</span></td><td class="text-nowrap">9:00 - 10:00 AM</td><td>Aaron Chapman</td><td class="text-end">10</td></tr><tr><th scope="row" class="fw-semibold">Wheel Pose Full Posture</th><td><span class="badge rounded-pill bg-primary-subtle text-primary-emphasis">Yoga</span></td><td class="text-nowrap">7:00 - 8:30 AM</td><td>Donna Wilson</td><td class="text-end">15</td></tr><tr><th scope="row" class="fw-semibold">Playful Dancer's Flow</th><td><span class="badge rounded-pill bg-primary-subtle text-primary-emphasis">Yoga</span></td><td class="text-nowrap">8:00 - 9:00 AM</td><td>Donna Wilson</td><td class="text-end">10</td></tr><tr><th scope="row" class="fw-semibold">Zumba Dance</th><td><span class="badge rounded-pill bg-primary-subtle text-primary-emphasis">Dance</span></td><td class="text-nowrap">5:00 - 7:00 PM</td><td>Donna Wilson</td><td class="text-end">20</td></tr><tr><th scope="row" class="fw-semibold">Cardio Blast</th><td><span class="badge rounded-pill bg-primary-subtle text-primary-emphasis">Gym</span></td><td class="text-nowrap">5:00 - 7:00 PM</td><td>Randy Porter</td><td class="text-end">10</td></tr><tr><th scope="row" class="fw-semibold">Pilates Reformer</th><td><span class="badge rounded-pill bg-primary-subtle text-primary-emphasis">Gym</span></td><td class="text-nowrap">8:00 - 9:00 AM</td><td>Randy Porter</td><td class="text-end">10</td></tr><tr><th scope="row" class="fw-semibold">Supple Spine and Shoulders</th><td><span class="badge rounded-pill bg-primary-subtle text-primary-emphasis">Yoga</span></td><td class="text-nowrap">6:30 - 8:00 AM</td><td>Donna Wilson</td><td class="text-end">15</td></tr><tr><th scope="row" class="fw-semibold">Yoga for Divas</th><td><span class="badge rounded-pill bg-primary-subtle text-primary-emphasis">Yoga</span></td><td class="text-nowrap">9:00 - 11:00 AM</td><td>Donna Wilson</td><td class="text-end">20</td></tr><tr><th scope="row" class="fw-semibold">Virtual Cycle</th><td><span class="badge rounded-pill bg-primary-subtle text-primary-emphasis">Gym</span></td><td class="text-nowrap">8:00 - 9:00 AM</td><td>Randy Porter</td><td class="text-end">20</td></tr><tr><th scope="row" class="fw-semibold">Heavy Bag Basics</th><td><span class="badge rounded-pill bg-primary-subtle text-primary-emphasis">Boxing</span></td><td class="text-nowrap">6:00 - 7:00 PM</td><td>Aaron Chapman</td><td class="text-end">12</td></tr></tbody>
        </table>
      </div>
    </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.