Snippets Dropdown

Bootstrap 5 Account Dropdown Menu

An account dropdown menu with a profile header, icon links, an activity badge and a sign-out action.

Bootstrap 5 No jQuery Mar 2020 2K views

<section class="wdw-stage">
  <div class="container d-flex justify-content-center" style="min-height: 34rem;">
    <div class="dropdown-center wdw-account" id="accountDropdown">
      <button class="btn wdw-acct-btn rounded-pill d-inline-flex align-items-center gap-2 ps-2 pe-3 dropdown-toggle" type="button" id="accountBtn" data-bs-toggle="dropdown" data-bs-auto-close="outside" aria-expanded="false">
        <img src="https://i.pravatar.cc/80?img=32" alt="" width="32" height="32" class="rounded-circle">
        <span class="fw-semibold">Elena Marsh</span>
      </button>
      <ul class="dropdown-menu shadow border-0 p-2 mt-3" aria-labelledby="accountBtn">
        <li class="px-3 py-3 d-flex align-items-center gap-3">
          <span class="position-relative flex-shrink-0">
            <img src="https://i.pravatar.cc/80?img=32" alt="" width="56" height="56" class="rounded-circle d-block">
            <span class="wdw-status" title="Online"><span class="visually-hidden">Online</span></span>
          </span>
          <div class="lh-sm">
            <p class="fw-bold mb-1 fs-5">Elena Marsh</p>
            <p class="small text-body-secondary mb-0">[email protected]</p>
          </div>
        </li>
        <li class="px-3 pb-3">
          <div class="d-flex justify-content-between small mb-1"><span class="fw-semibold">Pro plan</span><span class="text-body-secondary">7.2 of 10 GB</span></div>
          <div class="progress" role="progressbar" aria-label="Storage used" aria-valuenow="72" aria-valuemin="0" aria-valuemax="100" style="height:.5rem"><div class="progress-bar" style="width:72%"></div></div>
        </li>
        <li><hr class="dropdown-divider"></li>
        <li><a class="dropdown-item rounded-3 d-flex align-items-center gap-3 py-2" href="#"><svg class="flex-shrink-0" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="8" r="4"/><path d="M4 21a8 8 0 0 1 16 0"/></svg>Your profile<kbd class="ms-auto wdw-kbd">G P</kbd></a></li>
        <li><a class="dropdown-item rounded-3 d-flex align-items-center gap-3 py-2" href="#"><svg class="flex-shrink-0" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="3" width="7" height="9" rx="1.5"/><rect x="14" y="3" width="7" height="5" rx="1.5"/><rect x="14" y="12" width="7" height="9" rx="1.5"/><rect x="3" y="16" width="7" height="5" rx="1.5"/></svg>Your dashboard<kbd class="ms-auto wdw-kbd">G D</kbd></a></li>
        <li><a class="dropdown-item rounded-3 d-flex align-items-center gap-3 py-2" href="#"><svg class="flex-shrink-0" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 12h4l3-8 4 16 3-8h4"/></svg>Recent activity <span class="badge text-bg-primary rounded-pill ms-auto">3</span></a></li>
        <li><a class="dropdown-item rounded-3 d-flex align-items-center gap-3 py-2" href="#"><svg class="flex-shrink-0" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1.1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1.1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9a1.7 1.7 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z"/></svg>Settings<kbd class="ms-auto wdw-kbd">G S</kbd></a></li>
        <li><hr class="dropdown-divider"></li>
        <li class="px-3 py-2 d-flex align-items-center justify-content-between gap-3">
          <span class="small fw-semibold" id="acctThemeLabel">Theme</span>
          <div class="btn-group wdw-seg" role="group" aria-labelledby="acctThemeLabel">
            <input type="radio" class="btn-check" name="acctTheme" id="acctLight" value="light" autocomplete="off">
            <label class="btn btn-sm btn-outline-secondary" for="acctLight">Light</label>
            <input type="radio" class="btn-check" name="acctTheme" id="acctDark" value="dark" autocomplete="off">
            <label class="btn btn-sm btn-outline-secondary" for="acctDark">Dark</label>
          </div>
        </li>
        <li><hr class="dropdown-divider"></li>
        <li><a class="dropdown-item rounded-3 d-flex align-items-center gap-3 py-2 wdw-signout" href="#"><svg class="flex-shrink-0" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4M16 17l5-5-5-5M21 12H9"/></svg>Sign out<kbd class="ms-auto wdw-kbd">⇧Q</kbd></a></li>
      </ul>
    </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.