Skip to content

Hero with Search Bar

Bootstrap 6 directory hero on a photo background with a large pill search bar, a searchable area Combobox, popular search chips and category tiles.

Also known as: search bar hero banner, directory search hero, local listing search, search hero section

Hero with Search Bar live demo

Open in new tab

Bootstrap 6 code (HTML, CSS, JS)

A Bootstrap 6 hero for directory and local-listing sites. A large pill-shaped search bar sits over a dimmed restaurant photo. It pairs a free-text "What" field with a searchable "Where" Combobox, and below it are popular search chips, a live status line and six category tiles. It fits city guides, marketplaces and job boards.

How it works

The root .hsb-hero paints two backgrounds: the --hsb-overlay gradient over the --hsb-photo image. The headline uses a serif stack with an accent-colored italic word. On mobile .hsb-search is a stacked white card. From 768 px it becomes a three-column grid with a divider between the fields and a round Search button.

The "What" field is a Bootstrap 6 form-control form-adorn label holding a search icon and a borderless form-ghost input. "Where" is the new Bootstrap 6 Combobox: a combobox-toggle button with data-bs-toggle="combobox", data-bs-search="true" and data-bs-name="area", followed by a .menu of menu-item buttons. Downtown starts as selected, and Combobox creates a hidden area input for form submission.

script.js (an ES module) handles submit. An empty query adds .is-invalid to the form, shows .hsb-error and focuses the input. A valid query disables the button, shows a spinner-border spinner-sm, and after a short timeout writes a result count into the role="status" line. Each .hsb-chip fills the input and calls requestSubmit(). Picking a new area fires change.bs.combobox, which re-runs the search.

Customization

  • --hsb-photo on .hsb-hero: swap in your own background image. The photo comes from Unsplash; replace it with one of your city or venues.
  • --hsb-overlay: make the gradient lighter or darker to balance contrast with your photo.
  • --hsb-accent and --hsb-accent-dark: recolor the button, icons and italic word. The --bs-primary-* overrides beside them keep the Bootstrap button in sync.
  • Add or remove menu-item buttons with a data-bs-value to change the areas. Move the selected class to change the default.
  • Edit the .hsb-chip buttons for your own popular searches. Their text is what gets searched.
  • Replace the setTimeout in the submit handler with a fetch() to your search API. Read the area from the hidden area input.
  • Change grid-template-columns in .hsb-cats to show four or eight category tiles.

Use cases

  • City guides: a large pill search bar sits over a photo with a What field and a Where field
  • Marketplaces: popular search chips under the bar offer one-click starting points
  • Job boards: a searchable area picker helps visitors choose a location
  • Directory sites: six category tiles below the search help people browse

Accessibility

The form has role="search" and an aria-label. Each field has a visible label, and the error text is linked with aria-describedby and aria-invalid. The chips are real buttons with aria-pressed, and the result line is a polite live region. The Combobox supports arrow keys, Home/End, typing in its search box and Escape. All interactive elements have a visible focus ring, and the tile hover lift is turned off under prefers-reduced-motion.

Bootstrap 6 notes

The Combobox replaces a Bootstrap 5 form-select plus a third-party search plugin. The icon-in-input pattern uses form-adorn and form-ghost instead of an input-group. The button is btn-solid theme-primary, and the spinner size is spinner-sm. Built on Bootstrap 6.0.0-alpha.1, so APIs may change. In alpha.1 the Combobox logs a harmless "more than one instance" console message. Icons come from Bootstrap Icons.

Hero with Search Bar at a glance

Framework
Bootstrap 6
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
Bootstrap 6, Bootstrap Icons
Layout
Responsive, works on mobile
Category
Hero Sections
License
Free for personal and commercial use

Questions about this template

Can I use the Hero with Search Bar code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

Load Bootstrap 6 and Bootstrap Icons from a CDN (the links are under Requirements). Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

Add these to your page (already included in the download):

  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@6.0.0-alpha.1/dist/css/bootstrap.min.css">
  • <script type="module" src="https://cdn.jsdelivr.net/npm/bootstrap@6.0.0-alpha.1/dist/js/bootstrap.bundle.min.js"></script>
  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">

Built for Bootstrap 6.0.0-alpha.1. Bootstrap 6 ships as an ES module, so its script and this component's JavaScript load with type="module". Alpha releases can still change before the stable version.

Hero with Search Bar – Bootstrap 6 hero sections component screenshot
Hero with Search Bar · Bootstrap 6 Hero Sections

More Hero Sections

Split Hero with Diagonal Photo Clip – Pure CSS hero sections preview

Split Hero with Diagonal Photo Clip

Pure CSS split hero with headline, buttons and stats beside a full-height photo cut on a diagonal with clip-path, plus an accent stripe and rating badge.

Hero with Rotating Words – Pure CSS hero sections preview

Hero with Rotating Words

Dark hero section whose headline cycles through words with a slide-and-fade animation, a pause button and decorative stat cards.

Split Hero with App Screenshot – Tailwind CSS hero sections preview

Split Hero with App Screenshot

Dark Tailwind CSS split hero with gradient headline, two CTA buttons and an animated mock app dashboard built entirely from divs.

Dark Gradient Hero – Bootstrap 6 hero sections preview

Dark Gradient Hero

Dark Bootstrap 6 hero with a blurred gradient mesh, gradient headline, glowing CTA, copyable install command, decorative orb with stats and a row of trust logos.

Split Hero with Stats – Bootstrap 6 hero sections preview

Split Hero with Stats

Bootstrap 6 split hero with a highlighted headline, CTAs and avatar social proof beside a bento grid of key stats with a 12-month / all-time toggle.

SaaS Hero with App Screenshot – Bootstrap 6 hero sections preview

SaaS Hero with App Screenshot

Bootstrap 6 SaaS hero with a New badge, gradient headline, two CTAs and an app screenshot in a browser frame with switchable tabs and a tour Dialog.