Search-Engine-Style Hero — Free HTML CSS JS Snippet
Search-Engine-Style Hero · Heroes · Plain HTML, CSS & JS · Live preview
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>* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: system-ui, -apple-system, sans-serif; background: #fff; }
.sbc-hero { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.sbc-inner { width: 100%; max-width: 620px; display: flex; flex-direction: column; align-items: center; }
.sbc-logo { font-size: 32px; font-weight: 900; letter-spacing: -0.02em; color: #1e293b; margin-bottom: 36px; }
.sbc-searchwrap { position: relative; width: 100%; }
.sbc-icon { position: absolute; left: 20px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; fill: none; stroke: #94a3b8; stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.sbc-input {
width: 100%; padding: 17px 48px; border-radius: 999px; border: 1.5px solid #e2e8f0;
font-family: inherit; font-size: 16px; color: #0f172a; outline: none;
box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);
transition: border-color .15s, box-shadow .15s;
}
.sbc-input::placeholder { color: #94a3b8; }
.sbc-input:focus { border-color: #6366f1; box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12), 0 1px 4px rgba(15, 23, 42, 0.04); }
.sbc-clear {
position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
width: 26px; height: 26px; border-radius: 50%; border: none; background: #f1f5f9; color: #64748b;
font-size: 12px; cursor: pointer; display: none; align-items: center; justify-content: center;
transition: background .15s;
}
.sbc-clear:hover { background: #e2e8f0; }
.sbc-searchwrap.has-value .sbc-clear { display: flex; }
.sbc-chips { display: flex; flex-wrap: wrap; gap: 9px; justify-content: center; margin-top: 20px; }
.sbc-chip {
padding: 8px 16px; border-radius: 999px; border: 1px solid #e2e8f0; background: #f8fafc; color: #475569;
font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer; transition: background .15s, border-color .15s, color .15s;
}
.sbc-chip:hover { background: #eef2ff; border-color: #c7d2fe; color: #4338ca; }
@media (max-width: 480px) {
.sbc-logo { font-size: 26px; }
.sbc-input { padding: 15px 44px; font-size: 15px; }
}const wrap = document.querySelector('.sbc-searchwrap');
const input = document.getElementById('sbcInput');
const clearBtn = document.getElementById('sbcClear');
const chips = document.querySelectorAll('.sbc-chip');
function syncClearButton() {
wrap.classList.toggle('has-value', input.value.length > 0);
}
// Real focus/typing state — the clear button only appears once there's text
input.addEventListener('input', syncClearButton);
clearBtn.addEventListener('click', () => {
input.value = '';
syncClearButton();
input.focus();
});
// Suggestion chips fill the input and focus it, like a real search-engine homepage
chips.forEach((chip) => {
chip.addEventListener('click', () => {
input.value = chip.textContent;
syncClearButton();
input.focus();
});
});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.
What's included
Features
About this UI Snippet
Search-Engine-Style Hero — One Big Input as the Whole Homepage

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