Snippets Forms

Bootstrap 5 Hero Search Form with Location Field

A full-width travel hero with a location search bar, popular search chips and a photo background under a readable overlay.

Bootstrap 5 No jQuery May 2019 3.5K views

<section class="sf-hero d-flex align-items-center">
  <div class="container w-100 py-5" style="max-width:1000px">
    <span class="wdw-eyebrow text-white opacity-75">Travel & places</span>
    <h1 class="display-3 fw-bold text-white mt-2 mb-3" style="letter-spacing:-.03em">Discover the amazing city</h1>
    <p class="fs-4 text-white mb-4 opacity-75">Find hotels, restaurants and hidden gems wherever you are headed next.</p>
    <form class="sf-bar p-3 d-flex flex-column flex-md-row gap-2" role="search" id="sfForm">
      <div class="sf-field flex-md-grow-1 d-flex align-items-center gap-2 px-3">
        <svg 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>
        <label for="sfWhat" class="visually-hidden">What are you looking for?</label>
        <input id="sfWhat" class="form-control border-0 shadow-none bg-transparent px-0" type="search" placeholder="What are you looking for?">
      </div>
      <div class="sf-field sf-field-loc d-flex align-items-center gap-2 px-3">
        <svg 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="M12 21s7-6.2 7-11.5A7 7 0 0 0 5 9.5C5 14.8 12 21 12 21z"/><circle cx="12" cy="9.5" r="2.5"/></svg>
        <label for="sfWhere" class="visually-hidden">Location</label>
        <input id="sfWhere" class="form-control border-0 shadow-none bg-transparent px-0" type="text" placeholder="Location">
      </div>
      <button class="btn btn-primary rounded-pill px-4" type="submit">Search</button>
    </form>
    <p class="sf-result text-white mt-3 mb-0 small d-inline-block rounded-pill px-3 py-2" id="sfResult" aria-live="polite" hidden></p>
    <div class="d-flex flex-wrap gap-2 mt-4" aria-label="Popular searches">
      <span class="small text-white opacity-75 align-self-center me-1">Popular:</span>
      <button type="button" class="btn btn-sm rounded-pill sf-chip" data-q="Hotels">Hotels</button>
      <button type="button" class="btn btn-sm rounded-pill sf-chip" data-q="Restaurants">Restaurants</button>
      <button type="button" class="btn btn-sm rounded-pill sf-chip" data-q="Museums">Museums</button>
      <button type="button" class="btn btn-sm rounded-pill sf-chip" data-q="Nightlife">Nightlife</button>
    </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.