Snippets Bar

Bootstrap 5 Hero Header with Search Bar

A full-width photo hero with a rounded search bar combining keyword, budget and listing type, which stacks into a card on small screens.

Bootstrap 5 No jQuery Apr 2020 2K views

<section class="hs-hero d-flex align-items-center text-white" style="background-image:url('https://images.unsplash.com/photo-1560448204-e02f11c3d0e2?auto=format&fit=crop&w=1800&q=70')">
  <div class="hs-scrim"></div>
  <div class="container position-relative py-4" style="max-width:1000px">
    <header class="d-flex justify-content-between align-items-center mb-5">
      <a class="fw-bold fs-5 text-white text-decoration-none" href="#">Homeward</a>
      <a class="btn btn-outline-light btn-sm rounded-pill px-3" href="#">Sign in</a>
    </header>
    <div class="text-center mb-4">
      <h1 class="display-5 fw-bold mb-2">Find what you need</h1>
      <p class="lead mb-0 text-white">Discover top rated homes, shops and restaurants around the world.</p>
    </div>
    <form class="hs-form bg-body rounded-4 p-2 shadow-lg" role="search" id="hsForm">
      <div class="row g-2 align-items-center">
        <div class="col-12 col-md">
          <label class="visually-hidden" for="hsQ">What are you looking for</label>
          <input id="hsQ" type="search" class="form-control border-0 bg-transparent rounded-pill" placeholder="What are you looking for?">
        </div>
        <div class="col-6 col-md-3 hs-split">
          <label class="visually-hidden" for="hsBudget">Budget</label>
          <input id="hsBudget" type="number" min="0" class="form-control border-0 bg-transparent rounded-pill" placeholder="Budget ($)">
        </div>
        <div class="col-6 col-md-2 hs-split">
          <label class="visually-hidden" for="hsType">Listing type</label>
          <select id="hsType" class="form-select border-0 bg-transparent rounded-pill"><option>Rent</option><option>Buy</option><option>Sell</option></select>
        </div>
        <div class="col-12 col-md-auto">
          <button class="btn btn-primary rounded-pill w-100 px-4" type="submit"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m21 21-4.3-4.3"/></svg>Search</button>
        </div>
      </div>
    </form>
    <div class="d-flex flex-wrap justify-content-center gap-2 mt-4" role="group" aria-label="Quick filters">
      <button type="button" class="btn btn-outline-light btn-sm rounded-pill px-3 hs-chip">Apartments</button>
      <button type="button" class="btn btn-outline-light btn-sm rounded-pill px-3 hs-chip">Studios</button>
      <button type="button" class="btn btn-outline-light btn-sm rounded-pill px-3 hs-chip">Family homes</button>
    </div>
    <p class="text-center small text-white mt-3 mb-0" role="status" aria-live="polite" id="hsMsg">Browse by type or search above.</p>
    <div class="d-flex flex-wrap justify-content-center align-items-center gap-3 gap-md-4 mt-5 hs-proof">
      <div class="d-flex align-items-center gap-2">
        <div class="d-flex"><img class="rounded-circle border border-2 border-white" src="https://i.pravatar.cc/64?img=12" width="32" height="32" alt=""><img class="rounded-circle border border-2 border-white hs-ov" src="https://i.pravatar.cc/64?img=32" width="32" height="32" alt=""><img class="rounded-circle border border-2 border-white hs-ov" src="https://i.pravatar.cc/64?img=47" width="32" height="32" alt=""></div>
        <span class="small fw-semibold">Trusted by 50k+ renters</span>
      </div>
      <span class="small fw-semibold"><span class="fs-5 fw-bold">12k+</span> listings</span>
      <span class="small fw-semibold"><span class="fs-5 fw-bold">40</span> cities</span>
    </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.