36 CSS Search Bars

21 Pure CSS15 Light JSPublished 5 new designs · Updated on

36 copy-paste CSS search bars where the search bar IS the primary UI — command palette (⌘K), Algolia-style instant search with highlighted results, e-commerce product search with category scope, header navbar sticky search, SaaS dashboard command search with recent + suggested, voice input, autocomplete dropdowns, filter chips, recent searches, and 27 more design and interaction patterns. Scoped under .sb-NN, prefers-reduced-motion guarded, framework-agnostic.

Related28 CSS Input Fields16 CSS Floating Label Inputs22 CSS Dropdown Menu Designs20 CSS Kbd Keys17 Tailwind CSS Range Sliders

Premium icon pickPartner: Nucleo

Affiliate link

Need icons for the components you just copied?

You just browsed 36 searches. Nucleo is a library of 44,000+ SVG icons in five families (Core, UI, Sharp, Pixel and Micro Bold), with web, Mac and Windows apps to manage them. The All Icons Bundle is $149 with lifetime updates.

Get the Nucleo bundle

Nucleo. We may earn a commission, at no extra cost to you.

Published

Light JSNEW
The ⌘K palette every modern product ships — a native <dialog> that opens on Command/Control + K, filters grouped commands, pages and people as you type, moves an active option with the arrow keys through aria-activedescendant, and returns focus to the trigger on Escape. Blurred ::backdrop, a spring-in with @starting-style, and empty groups that hide themselves with :has().

Published

Light JSNEW
A marketing header where the search field collapses to an icon as the page scrolls and re-expands the moment you focus it. The shrink is a real scroll-driven animation (animation-timeline: scroll()) with an IntersectionObserver fallback, so it is smooth on modern browsers and correct everywhere else.
Newsletter

Enjoying these demos? Get new ones by email.

A short email when a new collection ships. Unsubscribe any time.

at

Almost there: check your inbox to confirm.Manage

09. Neon Glow CSS Search Bar (Cyberpunk) (opens in a new tab)

PublishedUpdated

Pure CSS
Cyan-and-magenta neon on near-black: the field's glow is a five-layer box-shadow — two tight inner rings for the tube, three wide outer washes for the bloom — and focus runs a slow hue-shifting pulse. Monospace type, scanline grid, zero JavaScript.

10. CSS Search Bar with Animated Caret Highlight (opens in a new tab)

PublishedUpdated

Light JS
An editor-grade field: the native caret is hidden and replaced with a glowing block cursor that tracks the real text width, blinking on a 1.06s square wave and dragging a soft highlight wash behind it. Measured with a mirrored span — no canvas, no font metrics guesswork.

PublishedUpdated

Light JS
Tap the mic and the field enters a listening state: concentric rings pulse out of the button, a live waveform of CSS bars reacts, and the placeholder changes to a listening prompt. State is one data-state attribute plus aria-pressed — no Web Speech API needed to build or test the UI.

12. CSS Search Bar with Loading Spinner Indicator (opens in a new tab)

PublishedUpdated

Light JS
Type and the magnifier morphs into a spinner while results are fetched, then settles into a result count. The spinner is a single element — a conic gradient masked into a ring — and the whole state machine is one data-state attribute with aria-busy for assistive tech.

14. Animated Expanding CSS Search Bar on Focus (opens in a new tab)

PublishedUpdated

Pure CSS
A 44px circle that unfurls into a full search field when focused and folds back when you leave — the toolbar pattern from Gmail, Figma and every dense app header. Pure CSS: :focus-within drives an eased inline-size transition, and the input keeps its accessible name the whole time.
Newsletter

Enjoying these demos? Get new ones by email.

A short email when a new collection ships. Unsubscribe any time.

at

Almost there: check your inbox to confirm.Manage

17. CSS Search Bar with Filter Chip Tags (opens in a new tab)

PublishedUpdated

Light JS
Filters live inside the field as removable chips sitting before the caret, GitHub/Linear style. The wrapper is a wrapping flex container, the input is a flex:1 child with a minimum width, and Backspace on an empty query pops the last chip — the interaction people expect and almost nobody implements.

19. CSS Search Bar with Rotating Placeholder Text (opens in a new tab)

PublishedUpdated

Pure CSS
The placeholder cycles through four real example queries — wireless headphones, invoice template, Q3 revenue, team photo — on a stacked-keyframe rotator with a blinking type cursor. It disappears the instant you type, and it is 100% CSS: the real placeholder attribute stays empty-but-present so :placeholder-shown still works.

PublishedUpdated

Light JS
The team-picker: selected people sit in the field as avatar chips, and typing filters a list of teammates with photos, roles and presence dots. Click or press Enter to add, click the chip's × (or Backspace) to remove — the assignee/mention pattern from Linear, Jira and Slack.

21. Neo-Brutalist CSS Search Bar with Offset Stamp (opens in a new tab)

PublishedUpdated

Pure CSS
Chunky 3px borders, zero-blur offset shadows, unapologetic yellow, and a rotated SEARCH stamp that snaps flat when you focus. The press interaction is the one everyone gets wrong: the shadow shrinks by exactly the distance the element moves, so the object looks pressed rather than shifted.
Newsletter

Enjoying these demos? Get new ones by email.

A short email when a new collection ships. Unsubscribe any time.

at

Almost there: check your inbox to confirm.Manage

PublishedUpdated

Pure CSS
A landing-page hero built around search: an oversized field with a solid CTA fused to its right edge, a fluid headline above and popular-query chips below. Everything scales with clamp(), and the CTA drops under the field on narrow screens without a media-query pile-up.

24. CSS Search Bar with Side Category Indicator (opens in a new tab)

PublishedUpdated

Pure CSS
A colour-coded search: pick Files, People, Messages or Code and a vertical bar on the input's leading edge changes colour and label to match. The state machine is a radio group read by :has() — no JavaScript, and the whole thing stays keyboard-operable because the controls are real radios.

26. CSS Search + Filter Sidebar Combo Bar (opens in a new tab)

PublishedUpdated

Pure CSS
A faceted-search sidebar: search at the top, then category checkboxes with result counts, a price range and an in-stock toggle. Every control is a native input styled with appearance:none, so keyboard, screen-reader and mobile behaviour are the browser's — not yours.

32. CSS Search Bar Combo with Scope Selector (opens in a new tab)

PublishedUpdated

Light JS
The developer-tool combo: a scope button on the left ("All files &#9662;") opening a menu of search scopes, with the query field beside it. The menu uses the Popover API — top-layer, light-dismiss and Escape handling with no JavaScript — plus CSS anchor positioning where available.

33. CSS Search Bar with Inset Pressed 3D Effect (opens in a new tab)

PublishedUpdated

Pure CSS
A field that looks carved into the surface: two inset shadows (dark from the top, light from the bottom) plus a 1px highlight on the lower lip. The 2027 take on neumorphism — depth without the contrast failures, because the text and icons stay on solid, accessible colours.

34. CSS Search Bar with Animated Border Trace (opens in a new tab)

PublishedUpdated

Pure CSS
On focus, a single accent stroke runs around the field like a light travelling a wire, then settles into a full outline. Drawn with an inline SVG rounded rect and stroke-dashoffset — pixel-crisp at any size, and immune to the corner artefacts gradient-border tricks produce.

35. Floating Card CSS Search Bar (Modal Style) (opens in a new tab)

PublishedUpdated

Light JS
Search-as-overlay: click the header field and a raised card floats above a dimmed, blurred page with a large input and recent result cards. A native <dialog> handles focus trapping, Escape and the backdrop — the pattern behind Notion, Vercel and most editorial sites.

36. Aurora Gradient CSS Search Bar (opens in a new tab)

PublishedUpdated

Pure CSS
The "AI product" field: a slow aurora of teal, violet and rose drifting around the border while a soft bloom of the same hues pools underneath. Driven by an @property-registered <angle> so a conic gradient can actually animate — the technique that makes this look impossible in plain CSS.
FAQ

Frequently asked questions

How do I build a Cmd+K command palette search bar in CSS?
Use the native <dialog> element with showModal() — the browser handles focus trapping, backdrop rendering, and ESC-to-close for free. Listen for keydown on document checking e.metaKey || e.ctrlKey combined with e.key === 'k', then call dialog.showModal() and prevent the browser's default find shortcut. Style the backdrop via dialog::backdrop with backdrop-filter: blur(). Focus the search input on open (dialog.querySelector('input').focus()), return focus to the trigger on close. Demo 01 in this collection ships the full recipe with keyboard-shortcut hint (⌘K badge) and a recent-commands list. Notion, Linear, Vercel, and Raycast all use this pattern.
How do I build an Algolia-style instant search with a highlighted results dropdown?
Two layers: the visual reveal is pure CSS via :focus-within on the wrapper (dropdown appears when input is focused, no JS needed). The highlight-matching-text effect uses a <mark> element wrapping the matched substring, styled with an accent background. For a real integration you'd swap the static mock results for fetch('/api/search?q=' + query) on each input event with a 150-300ms debounce. Group results by category using <ul role='listbox'> with <li role='option'> items and aria-activedescendant on the input. Demo 02 ships the visual pattern; wire your search API on top.
What's the right HTML for a CSS search bar?
Wrap <input type='search'> inside a <form role='search'> with a real <label> (visually hidden if needed). The type='search' adds a clear button on Chromium browsers and triggers correct virtual keyboards on mobile; role='search' is the WAI-ARIA landmark so screen-reader users can jump directly to search from anywhere on the page. Never rely on placeholder alone as the label — screen readers don't announce placeholders reliably and low-vision users lose the label on focus. Every demo in this collection uses this pattern.
How do I make a clear button appear only when there's text in the search input?
Pure CSS, no JavaScript. Use the :placeholder-shown pseudo-class: when the field is empty the placeholder is shown, so input:placeholder-shown ~ .clear { opacity: 0; pointer-events: none; }. When the user types, the placeholder hides and the clear button becomes visible. Combine with :has() to drive parent state (e.g. show a border color change when there's typed content). Demo 13 ships this pattern with animation and ARIA on the clear button.
How do I add a search animation when the input is focused?
Animate on :focus or :focus-within. Common patterns: a collapsed icon-only bar that expands its width to a full input on focus (width transition), an underline that wipes in from left to right (transform: scaleX() on a ::after pseudo-element), a magnifier icon that slides and morphs into a clear-X (SVG stroke animation), an animated border trace (SVG stroke-dashoffset or conic-gradient with @property), or a soft glow ring (multi-layer box-shadow with transform: scale). All done with transition — zero JavaScript. Demos 06, 10, 14, 28, 31, 34 show six different focus-driven animation approaches.
How is this different from generic input collections like css-input-fields?
css-input-fields (28 demos) covers generic text/email/password/number/textarea patterns. css-floating-label-inputs (17 demos) covers the specific floating-label pattern across every input type. This collection focuses on **search-bar-specific product surfaces**: command palettes (⌘K), Algolia-style instant search dropdowns, e-commerce product search with category scope, header navbar sticky search that shrinks on scroll, SaaS dashboard command search with recent + suggested, plus 31 more design and interaction patterns where the search bar IS the primary UI. If you need a generic text input, use css-input-fields; if you need a search bar with product context, you're in the right place.
Are these CSS search bars accessible?
Yes. Every demo uses a real <label> associated with <input type='search'> inside a <form role='search'> landmark. Voice, clear, and submit buttons have aria-label describing the action. Autocomplete dropdowns implement the WAI-ARIA combobox pattern (aria-controls, aria-expanded, aria-activedescendant, role='listbox' on the dropdown, role='option' on items). Command palette (Demo 01) traps focus inside the <dialog> element, closes on ESC, and returns focus to the trigger. Every demo with motion respects @media (prefers-reduced-motion: reduce). Focus rings are visible on every interactive element (2px minimum, high contrast per WCAG 2.4.11).
Do I need JavaScript for autocomplete, recent searches, and voice input?
Yes for the data, no for most of the visuals. The dropdowns themselves open and close via :focus-within or :checked — pure CSS. JS is only needed to filter results based on typed input (with a 150-300ms debounce), persist recent searches in localStorage, or trigger the Web Speech API for real voice input. Command palette (Demo 01), instant search (Demo 02), e-commerce scope (Demo 03), navbar sticky (Demo 04), SaaS dashboard (Demo 05), voice input (Demo 11), and loading spinner (Demo 12) each ship self-contained JS snippets under 30 lines with zero dependencies — copy and adapt for your framework.

Related collections

15 CSS 3D Tilt Hover Cards preview

15 CSS 3D Tilt Hover Cards

15 mouse-aware 3D tilt hover cards — e-commerce product spotlight, glassmorphism parallax team card, interactive pricing tier, holographic NFT collectible, pop-out mascot, dark tech grid with border glow, media player album art, blog article preview, cyberpunk neon glow, dashboard KPI widget, minimalist real estate, flip-to-back tilt, mobile app showcase, course learning card, and a Pure CSS touch-friendly tilt. Vanilla JS writes --rx/--ry/--mx/--my; all rendering stays in CSS on the GPU.

24 CSS Animated Cards preview

24 CSS Animated Cards

24 hand-coded CSS animated card patterns organised by what triggers the motion, not by card style. Scroll and entrance triggers: staggered grid reveals, @starting-style mount-in, scroll-driven scale and fade on animation-timeline: view(), View Transitions API card-to-detail morphs, blur-to-sharp lazy image loading, and FLIP re-layout when a filter changes. State-change triggers: add-to-cart success morph, like and save particle burst, expand and collapse to intrinsic height with calc-size(), swipe-to-dismiss on Pointer Events, and skeleton-to-loaded crossfade. Data-driven triggers: count-up KPI metrics, SVG sparkline draw-on-enter, and progress ring fill on load. Ambient idle loops: breathing glow, floating drift, animated gradient mesh backgrounds, conic rotating borders, auto-cycling testimonial decks, and live status pulses. Plus four hover patterns where the effect is the topic itself: cursor spotlight, holographic foil glare, corner ribbon slide, and horizontal accordion expand. Every card is scoped under a .ac-NN prefix for no-collision pasting, guards prefers-reduced-motion, animates compositor-only properties, and ports unchanged to React, Vue, Svelte, Astro, Next.js and Tailwind.

22 CSS Avatars preview

22 CSS Avatars

22 hand-coded CSS avatars for chat apps, team dashboards, comment threads, account menus, and social profiles. Covers circular and squircle shapes, gradient and conic story rings, hexagon clip-path crops, online status dots, notification count badges, verified checkmarks, stacked facepiles with plus-N overflow, initials fallbacks for users without photos, broken-image recovery, avatar pickers, and a size scale system where the ring, badge, and status dot all scale from a single custom property.

Search CodeFronts

Loading…