Snippets Modal

Bootstrap 5 Modal with Vertical Tabs

A modal with vertical side tabs for apps, a help centre, communities and learning preferences, collapsing to a scrollable tab strip on phones.

Bootstrap 5 No jQuery Jun 2020 11.4K views

<section class="mt-section wdw-stage">
  <header class="mt-top d-flex align-items-center justify-content-between px-3 px-md-4 py-3 bg-body border-bottom">
    <span class="fw-bold d-flex align-items-center gap-2"><span class="mt-brand" aria-hidden="true"></span>Acme workspace</span>
    <button type="button" class="btn btn-sm btn-outline-primary rounded-pill px-3" data-bs-toggle="modal" data-bs-target="#mt-modal">Open hub</button>
  </header>
  <div class="container text-center mt-wrap">
    <span class="wdw-eyebrow mb-3">Modal + tabs</span>
    <h1 class="display-5 wdw-heading mb-3">Everything in one place</h1>
    <p class="lead text-body-secondary mx-auto mb-4 mt-lead">Open a modal with side tabs for your apps, help articles, communities and learning preferences.</p>
    <button type="button" class="btn btn-primary rounded-pill px-5" data-bs-toggle="modal" data-bs-target="#mt-modal">Open hub</button>
  </div>

  <div class="modal fade" id="mt-modal" tabindex="-1" aria-labelledby="mt-title" aria-hidden="true">
    <div class="modal-dialog modal-xl modal-dialog-centered modal-dialog-scrollable">
      <div class="modal-content border-0 rounded-4 overflow-hidden">
        <div class="modal-header border-0 pb-2 px-4 pt-4">
          <div><h2 class="modal-title h4 wdw-heading mb-0" id="mt-title">Your hub</h2><p class="text-body-secondary small mb-0">Workspace <span aria-hidden="true">·</span> <span id="mt-section" aria-live="polite">My Apps</span></p></div>
          <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
        </div>
        <div class="modal-body px-4 mt-body">
          <div class="row g-4">
            <div class="col-md-4 d-flex flex-column gap-3">
              <div class="nav nav-pills flex-md-column gap-1 mt-nav" role="tablist" aria-orientation="vertical">
          <button class="nav-link text-start d-flex align-items-center gap-2 active" id="mt-tab-0" data-bs-toggle="pill" data-bs-target="#mt-pane-0" type="button" role="tab" aria-controls="mt-pane-0" aria-selected="true"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="3" width="7" height="7" rx="2"/><rect x="14" y="3" width="7" height="7" rx="2"/><rect x="3" y="14" width="7" height="7" rx="2"/><rect x="14" y="14" width="7" height="7" rx="2"/></svg><span>My Apps</span></button>
          <button class="nav-link text-start d-flex align-items-center gap-2" id="mt-tab-1" data-bs-toggle="pill" data-bs-target="#mt-pane-1" type="button" role="tab" aria-controls="mt-pane-1" aria-selected="false"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 5a2 2 0 0 1 2-2h13v16H6a2 2 0 0 0-2 2z"/><path d="M4 21V5"/></svg><span>Knowledge Center</span></button>
          <button class="nav-link text-start d-flex align-items-center gap-2" id="mt-tab-2" data-bs-toggle="pill" data-bs-target="#mt-pane-2" type="button" role="tab" aria-controls="mt-pane-2" aria-selected="false"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="9" cy="8" r="3.500"/><path d="M2.500 20a6.500 6.500 0 0 1 13 0"/><path d="M16 4.500a3.500 3.500 0 0 1 0 7M21.500 20a6.500 6.500 0 0 0-4-6"/></svg><span>Communities</span></button>
          <button class="nav-link text-start d-flex align-items-center gap-2" id="mt-tab-3" data-bs-toggle="pill" data-bs-target="#mt-pane-3" type="button" role="tab" aria-controls="mt-pane-3" aria-selected="false"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 9l10-5 10 5-10 5z"/><path d="M6 11.500V17c3 2.500 9 2.500 12 0v-5.500"/></svg><span>Education</span></button>
          </div>
              <div class="mt-storage mt-auto d-none d-md-block" aria-label="Storage usage">
                <div class="d-flex justify-content-between small mb-2"><span class="fw-semibold">Storage</span><span class="text-body-secondary">6.2 of 10 GB</span></div>
                <div class="progress" role="progressbar" aria-label="Storage used" aria-valuenow="62" aria-valuemin="0" aria-valuemax="100" style="height:6px"><div class="progress-bar" style="width:62%"></div></div>
              </div>
            </div>
            <div class="col-md-8"><div class="tab-content">
          <div class="tab-pane fade show active" id="mt-pane-0" role="tabpanel" aria-labelledby="mt-tab-0" tabindex="0">
            <h3 class="h5 fw-bold mb-1">My Apps</h3><p class="text-body-secondary small">Your most used and suggested apps.</p>
            <div class="d-flex flex-wrap gap-2 mb-4" role="group" aria-label="Pinned apps"><input type="checkbox" class="btn-check" id="mt-chip0" autocomplete="off" checked><label class="mt-chip rounded-pill" for="mt-chip0">WhatsApp</label><input type="checkbox" class="btn-check" id="mt-chip1" autocomplete="off"><label class="mt-chip rounded-pill" for="mt-chip1">Instagram</label><input type="checkbox" class="btn-check" id="mt-chip2" autocomplete="off" checked><label class="mt-chip rounded-pill" for="mt-chip2">Chrome</label><input type="checkbox" class="btn-check" id="mt-chip3" autocomplete="off"><label class="mt-chip rounded-pill" for="mt-chip3">LinkedIn</label></div>
            <h4 class="h6 text-uppercase text-body-secondary fw-semibold">Suggested</h4>
            <div class="list-group mt-apps"><a href="#" class="list-group-item list-group-item-action d-flex align-items-center gap-3 border-0 rounded-3 px-2 py-2"><span class="mt-app wdw-icon" aria-hidden="true"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"/><ellipse cx="12" cy="12" rx="3.500" ry="6"/></svg></span><div><div class="fw-semibold">Opera Browser</div><small class="text-body-secondary">One of the best browsers</small></div><span class="ms-auto d-flex align-items-center gap-1 text-body-secondary small mt-open">Open<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m9 6 6 6-6 6"/></svg></span></a><a href="#" class="list-group-item list-group-item-action d-flex align-items-center gap-3 border-0 rounded-3 px-2 py-2"><span class="mt-app wdw-icon" aria-hidden="true"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 8V5h3M20 8V5h-3M4 16v3h3M20 16v3h-3"/><path d="M4 12h16"/></svg></span><div><div class="fw-semibold">CamScanner</div><small class="text-body-secondary">Easily scan your documents</small></div><span class="ms-auto d-flex align-items-center gap-1 text-body-secondary small mt-open">Open<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m9 6 6 6-6 6"/></svg></span></a><a href="#" class="list-group-item list-group-item-action d-flex align-items-center gap-3 border-0 rounded-3 px-2 py-2"><span class="mt-app wdw-icon" aria-hidden="true"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 9l10-5 10 5-10 5z"/><path d="M6 11.500V17c3 2.500 9 2.500 12 0v-5.500"/></svg></span><div><div class="fw-semibold">Coursera</div><small class="text-body-secondary">Learn online from top universities</small></div><span class="ms-auto d-flex align-items-center gap-1 text-body-secondary small mt-open">Open<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m9 6 6 6-6 6"/></svg></span></a></div>
          </div>
          <div class="tab-pane fade" id="mt-pane-1" role="tabpanel" aria-labelledby="mt-tab-1" tabindex="0">
            <h3 class="h5 fw-bold mb-1">Knowledge Center</h3><p class="text-body-secondary small">Find guides for the product you use.</p>
            <label for="mt-product" class="form-label small fw-semibold">Product</label>
            <select id="mt-product" class="form-select mb-4"><option selected disabled>Select product</option><option>Product 1</option><option>Product 2</option><option>Product 3</option></select>
            <h4 class="h6 text-uppercase text-body-secondary fw-semibold">Popular topics</h4>
            <div class="list-group">
              <a href="#" class="list-group-item list-group-item-action">Getting started</a>
              <a href="#" class="list-group-item list-group-item-action">Creating tests</a>
              <a href="#" class="list-group-item list-group-item-action">Running tests</a>
            </div>
          </div>
          <div class="tab-pane fade" id="mt-pane-2" role="tabpanel" aria-labelledby="mt-tab-2" tabindex="0">
            <div class="d-flex justify-content-between align-items-start mb-3"><div><h3 class="h5 fw-bold mb-1">Communities</h3><p class="text-body-secondary small mb-0">Groups you belong to.</p></div><button type="button" class="btn btn-primary btn-sm rounded-pill px-3">New community</button></div>
            <div class="vstack gap-3">
              <div class="p-3 border rounded-4 d-flex justify-content-between align-items-center"><div><div class="fw-semibold">Community 1</div><small class="text-body-secondary">Design & product</small></div><span class="badge text-bg-light border rounded-pill">27 members</span></div>
              <div class="p-3 border rounded-4 d-flex justify-content-between align-items-center"><div><div class="fw-semibold">Community 2</div><small class="text-body-secondary">Front-end engineers</small></div><span class="badge text-bg-light border rounded-pill">16 members</span></div>
            </div>
          </div>
          <div class="tab-pane fade" id="mt-pane-3" role="tabpanel" aria-labelledby="mt-tab-3" tabindex="0">
            <h3 class="h5 fw-bold mb-1">Education</h3><p class="text-body-secondary small">Tell us what you want to learn.</p>
            <fieldset><legend class="h6 mb-3">What are you good at?</legend>
              <div class="form-check mb-2"><input class="form-check-input" type="checkbox" id="mt-o1" checked><label class="form-check-label" for="mt-o1">Web development</label></div>
              <div class="form-check mb-2"><input class="form-check-input" type="checkbox" id="mt-o2"><label class="form-check-label" for="mt-o2">Data structures & algorithms</label></div>
              <div class="form-check mb-4"><input class="form-check-input" type="checkbox" id="mt-o3"><label class="form-check-label" for="mt-o3">Design</label></div>
            </fieldset>
                      </div>
            </div></div>
          </div>
        </div>
        <div class="modal-footer border-0 px-4 pb-4 pt-2">
          <button type="button" class="btn btn-outline-secondary text-body rounded-pill px-4" data-bs-dismiss="modal">Close</button>
          <button type="button" class="btn btn-primary rounded-pill px-4" data-bs-dismiss="modal">Save changes</button>
        </div>
      </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.