Sticky Search Header
A copy-paste search & autocomplete component in pure HTML, CSS & vanilla JS. Zero dependencies, framework-agnostic, MIT-licensed.
Search & AutocompleteHTMLJavaScriptCSSany framework
Components
Copy into your project
HTML
<header class="nuda-sticksrch">
<span>Components</span>
<div class="nuda-sticksrch__field">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="11" cy="11" r="7" />
<path d="m21 21-4.3-4.3" />
</svg>
<input placeholder="Filter…" />
</div>
</header>JavaScript
// Add .is-stuck once the header crosses a threshold
const header = document.querySelector('.nuda-sticksrch');
const onScroll = () => {
header.classList.toggle('is-stuck', window.scrollY > 60);
};
window.addEventListener('scroll', onScroll, { passive: true });
onScroll();CSS
.nuda-sticksrch {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
padding: 10px 14px;
background: rgba(17,17,20,.5);
border: 1px solid rgba(255,255,255,.06);
border-radius: 12px;
width: 100%;
max-width: 280px;
transition: background .3s,backdrop-filter .3s,box-shadow .3s,padding .3s;
}
.nuda-sticksrch.is-stuck {
background: rgba(17,17,20,.85);
backdrop-filter: blur(14px);
box-shadow: 0 4px 16px -8px rgba(0,0,0,.5);
padding: 8px 14px;
}
.nuda-sticksrch > span {
color: #fafafa;
font-size: 12px;
font-weight: 600;
}
.nuda-sticksrch__field {
display: flex;
align-items: center;
gap: 6px;
padding: 5px 10px;
background: rgba(0,0,0,.3);
border: 1px solid rgba(255,255,255,.06);
border-radius: 8px;
width: 120px;
transition: width .35s cubic-bezier(.16,1,.3,1);
}
.nuda-sticksrch__field:focus-within {
width: 160px;
border-color: #e4ff54;
}
.nuda-sticksrch__field svg {
width: 11px;
height: 11px;
color: #63636e;
flex-shrink: 0;
}
.nuda-sticksrch__field input {
flex: 1;
min-width: 0;
background: transparent;
border: 0;
outline: none;
color: #fafafa;
font-size: 11px;
}
.nuda-sticksrch__field input::placeholder {
color: #63636e;
}
How to use Sticky Search Header
Paste the HTML where you need it and the CSS into a global stylesheet (or a <style> tag). Every class is prefixed nuda- so it never collides with Tailwind or your own styles. Tweak the CSS custom properties to match your design system.
Works in React, Vue, Svelte, Astro, Next.js, Nuxt, Laravel Blade, Django, Rails — or a single .html file. No npm install, no build step.