webdevpuneet.com

Search-Engine-Style Hero — Free HTML CSS JS Snippet

Search-Engine-Style Hero · Heroes · Plain HTML, CSS & JS · Live preview

CategoryHeroes

Copy & paste

Source Code

<section class="sbc-hero">
  <div class="sbc-inner">
    <div class="sbc-logo">Findly</div>

    <div class="sbc-searchwrap">
      <svg class="sbc-icon" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m21 21-4.3-4.3"/></svg>
      <input class="sbc-input" id="sbcInput" type="text" placeholder="Search docs, guides, and API references" aria-label="Search" autocomplete="off">
      <button class="sbc-clear" id="sbcClear" aria-label="Clear search" type="button">✕</button>
    </div>

    <div class="sbc-chips" id="sbcChips">
      <button class="sbc-chip" type="button">Getting started</button>
      <button class="sbc-chip" type="button">Authentication</button>
      <button class="sbc-chip" type="button">Webhooks</button>
      <button class="sbc-chip" type="button">Rate limits</button>
      <button class="sbc-chip" type="button">Pricing</button>
    </div>
  </div>
</section>

Extend with AI

Take This Snippet Further With AI

The AI prompt for this one is for Patreon supporters ($3 a month), along with a site with no ads. Supporters enter the passcode once and it is remembered in this browser.

· Become a supporter

What's included

Features

Search as the whole hero
No competing headline or CTA — the input is the primary action.
Real focus state
A genuine border and box-shadow glow on focus, not a static screenshot.
Working clear button
Appears only once there's real text, tracked with an input listener.
Functional suggestion chips
Clicking a chip fills and focuses the input like a typed query.
Pill-shaped input
Heavy padding and full border-radius read as one confident action.
Zero visual clutter
Generous whitespace keeps attention on a single decision.
Accessible labeling
aria-label on the input and clear button for screen readers.
Responsive sizing
Padding and font size scale down under 480px.

About this UI Snippet

Search-Engine-Style Hero — One Big Input as the Whole Homepage

Screenshot of the Search-Engine-Style Hero snippet rendered live

Most marketing heroes lead with a headline and a CTA button. This one leads with a search box — the search-engine-homepage pattern, where the input itself is the primary and only interactive element, and everything else (a logo, a handful of suggestion chips) exists to support it. It's the right hero for a docs site, an internal tool, or any product whose entire value proposition is "find the thing fast."

Minimalism as a design decision, not an oversight

There's no headline, no subheading, no CTA button competing for attention — just a logo mark and one large pill-shaped input, centered in the viewport with generous surrounding whitespace. This isn't a stripped-down placeholder; it's a deliberate echo of the search-engine homepage pattern (Google, Algolia's own doc search, Kagi), which works because it removes every decision except "type and go."

A real, working input, not a static mockup

The input has a genuine focus ring (border-color shift plus a soft box-shadow glow) and a clear button that only appears once there's actual text in the field — tracked with a real input event listener, not just CSS :placeholder-shown tricks. Clicking the clear button empties the field, hides itself again, and returns focus to the input, the same round-trip a real search UI needs.

Suggestion chips that actually populate the field

Below the input, a row of topic chips (Getting started, Authentication, Webhooks...) are real buttons wired with click handlers that set the input's value to the chip's label and refocus the field — clicking a chip functions exactly like typing that query yourself, including making the clear button appear. This is the same pattern search and docs sites use for zero-effort query suggestions.

Why a pill shape and heavy padding

The border-radius: 999px pill shape and generous 17px vertical padding are deliberate: a search input this size reads as a single confident action rather than a form field to fill out, and the large touch target matters as much on mobile as it does for visual weight on desktop.

Customizing it

Wire the input event or a submit trigger (Enter key, or add a submit button) to your actual search endpoint or client-side search index. Replace the suggestion chips with your product's real popular queries or categories. Swap the logo for your wordmark, and adjust the accent color used in the focus ring and chip-hover state to match your brand.

Step by step

How to Use

  1. 1
    Paste the HTML, CSS, and JSA minimal hero renders — a logo, a large pill-shaped search input, and suggestion chips.
  2. 2
    Click into the inputA focus ring appears around the field.
  3. 3
    Type a queryA clear button fades in on the right; clicking it empties the field and refocuses it.
  4. 4
    Click a suggestion chipThe input fills with that chip's text and refocuses, exactly as if you'd typed it.
  5. 5
    Wire up real searchConnect the input event (or an Enter/submit trigger) to your search endpoint or index.
  6. 6
    Customize the chipsReplace the five suggestions with your product's real popular queries.

Real-world uses

Common Use Cases

Documentation site homepages
Lead with search instead of a marketing pitch when users arrive to find something specific.
Internal tools and knowledge bases
Pair with a search box used elsewhere in the app for consistency.
Search products and directories
The obvious hero pattern when search is the entire product.
API reference and developer portals
Chips can surface top endpoints or guides instead of marketing links.
Help centers and support portals
Reduce ticket volume by making self-serve search the first thing visitors see.
Learning minimal, single-action hero design
A reference for stripping a hero down to one clear interaction.
Related: Hero with 3D Tilting Product Mockup
See the Hero with 3D Tilting Product Mockup for a related heroes pattern worth pairing with this one.

Got questions?

Frequently Asked Questions

An input event listener checks input.value.length on every keystroke and toggles a has-value class on the wrapping element. The CSS only displays .sbc-clear when that class is present, so the button genuinely tracks the field's real content rather than relying on a CSS-only :placeholder-shown trick, which wouldn't reset correctly after the field is cleared programmatically.

Each chip has its own click handler that sets the input's value to the chip's text content and calls input.focus(). This also triggers the same has-value state update as manual typing would (the code calls the same sync function), so the clear button appears immediately, exactly matching the behavior of typing the query yourself.

No — it handles the input's visual and interaction states (focus, clear, chip-fill) but doesn't call any search API or filter any data, since that depends entirely on your backend or search index. Wire a submit handler (Enter keypress, or add a submit button) to your real search endpoint or a client-side library like Fuse.js or Algolia's InstantSearch.

A fully rounded, heavily padded input reads as a single confident action rather than one field among many in a form — the search-engine-homepage convention. It also gives a larger, easier touch target on mobile, which matters when the input is the hero's only interactive element.

Hold the query string in state. The input's onChange updates it and derives the has-value condition directly from the string's length (no separate class-toggling needed). Each chip's onClick sets the same state value. Bind the clear button's visibility to query.length > 0. Click JSX, Vue, or Angular in the export panel for the converted component.