Snippets Bar

Bootstrap 5 Hero Search Box with Image Background

A hero banner with a photo background, a prominent pill search bar and quick-pick suggestion chips.

Bootstrap 5 Bootstrap 6 No jQuery Aug 2020 3.6K views

<section class="wdw-hero position-relative overflow-hidden text-white d-flex align-items-center" style="min-height:100vh;background-image:url('https://images.unsplash.com/photo-1470229722913-7c0e2dbbafd3?auto=format&fit=crop&w=1600&q=70')">
  <div class="wdw-hero-tint wdw-aurora position-absolute top-0 start-0 w-100 h-100" aria-hidden="true"></div>
  <div class="wdw-hero-scrim position-absolute top-0 start-0 w-100 h-100" aria-hidden="true"></div>
  <div class="container position-relative py-5 text-center" style="max-width:1000px">
    <span class="badge rounded-pill border border-light border-opacity-25 text-white mb-3 px-3 py-2" style="background:rgba(255,255,255,.16)">Community search</span>
    <h1 class="display-5 fw-bold mb-2" style="letter-spacing:-.02em">Connect. Discover. Share.</h1>
    <p class="lead text-white mb-4 mx-auto" style="max-width:34rem;opacity:.92">Find artists, gigs and stories from people in our music community.</p>
    <form class="wdw-search mx-auto" role="search" id="hero-search">
      <label for="hero-q" class="visually-hidden">Search the community</label>
      <svg class="wdw-search-icon" 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"><circle cx="11" cy="11" r="7"/><path d="M20 20l-3.5-3.5"/></svg>
      <input id="hero-q" type="search" class="form-control border-0 shadow-none" placeholder="Search artists, gigs..." autocomplete="off">
      <button class="btn btn-primary rounded-pill px-4" type="submit">Search</button>
    </form>
    <p class="small fw-semibold mt-4 mb-2 text-white" id="chips-label" style="opacity:.9">Popular searches</p>
    <div class="d-flex flex-wrap justify-content-center gap-2" role="group" aria-labelledby="chips-label">
      <button type="button" class="wdw-chip" data-q="Live sessions" aria-pressed="false">Live sessions</button>
      <button type="button" class="wdw-chip" data-q="Guitar lessons" aria-pressed="false">Guitar lessons</button>
      <button type="button" class="wdw-chip" data-q="Local venues" aria-pressed="false">Local venues</button>
      <button type="button" class="wdw-chip" data-q="Vinyl swaps" aria-pressed="false">Vinyl swaps</button>
    </div>
    <p id="hero-msg" class="small fw-semibold mt-3 mb-0 text-white" style="opacity:.92" role="status" aria-live="polite"></p>
  </div>
</section>

Built on Bootstrap 6.0.0-alpha.1 (ES modules, no jQuery). Load Bootstrap through an import map and run the JavaScript as type="module" — the downloaded file is already set up that way. Alpha releases can still change class names.

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