Snippets Buttons

Bootstrap 5 Go to Home Button with Hover Effect

A go-to-home button with a sliding arrow on hover and focus, shown in a not-found hero alongside two more hover treatments: a fill sweep and an icon swap.

Bootstrap 5 No jQuery Aug 2019 2.1K views

<section class="wdw-stage">
  <div class="container" style="max-width:720px">
    <div class="wdw-card overflow-hidden">
      <div class="wdw-aurora text-center px-4 py-5">
        <span class="wdw-eyebrow text-white-50 mb-2">Error 404</span>
        <h1 class="fw-bold text-white display-6 mb-2">This page took a wrong turn</h1>
        <p class="text-white-50 mb-4 mx-auto" style="max-width:30rem">It has moved or no longer exists. Head back home and pick up from there.</p>
        <div class="d-flex flex-column flex-sm-row justify-content-center align-items-center gap-3">
          <a href="#" class="btn btn-light btn-lg rounded-pill btn-home px-4"><svg class="ico-home" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 10.5L12 3l9 7.5"/><path d="M5 9.5V20h5v-6h4v6h5V9.5"/></svg><span>Go to home</span><svg class="home-arrow" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14"/><path d="M13 6l6 6-6 6"/></svg></a>
          <a href="#" class="btn btn-outline-light rounded-pill">Contact support</a>
        </div>
      </div>
      <div class="p-4">
        <p class="wdw-eyebrow mb-3">More hover styles</p>
        <div class="row g-3 text-center">
          <div class="col-sm-4">
            <a href="#" class="btn btn-outline-primary rounded-pill w-100 btn-home">Go to home<svg class="home-arrow" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14"/><path d="M13 6l6 6-6 6"/></svg></a>
            <div class="small wdw-muted mt-2">Style 1 · Arrow slide</div>
          </div>
          <div class="col-sm-4">
            <a href="#" class="btn btn-outline-primary rounded-pill w-100 btn-sweep"><span>Go to home</span></a>
            <div class="small wdw-muted mt-2">Style 2 · Fill sweep</div>
          </div>
          <div class="col-sm-4">
            <a href="#" class="btn btn-outline-primary rounded-pill w-100 btn-swap"><span class="swap-ico"><svg class="ico-home" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 10.5L12 3l9 7.5"/><path d="M5 9.5V20h5v-6h4v6h5V9.5"/></svg><svg class="swap-alt" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M19 12H5"/><path d="M11 6l-6 6 6 6"/></svg></span><span>Go to home</span></a>
            <div class="small wdw-muted mt-2">Style 3 · Icon swap</div>
          </div>
        </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.