36 CSS Search Bars

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.

21 pure CSS15 light JSPublished 5 new designs · Updated on

Related28 CSS Input Fields16 CSS Floating Label Inputs22 CSS Dropdown Menu Designs20 CSS Kbd Keys

Command Palette Cmd+K Search Bar — preview
01 / 36Light JSNEW

Command Palette Cmd+K Search Bar

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

Algolia-Style Instant Search with Highlighted Results Dropdown — preview
02 / 36Pure CSSNEW

Algolia-Style Instant Search with Highlighted Results Dropdown

An instant-search dropdown in the DocSearch/Algolia idiom: focus the field and a panel opens with results grouped under Products, Categories and Help articles, each row a thumbnail or icon plus title, description and the matched substring wrapped in <mark>. The reveal is :focus-within — no JavaScript at all.

Published

E-Commerce Product Search Bar with Category Scope Dropdown — preview
03 / 36Light JSNEW

E-Commerce Product Search Bar with Category Scope Dropdown

The retailer pattern: a department <select> on the left, the query in the middle, a solid submit button on the right, all fused into one 48px bar inside a mock storefront header. Trending suggestions open on :focus-within; the submit button spins for the round trip via a data-state flip.

Published

Header Navbar Integrated Sticky Search Bar — preview
04 / 36Light JSNEW

Header Navbar Integrated Sticky Search Bar

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.

Published

SaaS Dashboard Command Search with Recent and Suggested — preview
05 / 36Light JSNEW

SaaS Dashboard Command Search with Recent and Suggested

The persistent dashboard topbar search: focus it and a rich panel opens with Recent (clock icons), Suggested (sparkle icons) and Quick actions with real ⌘ shortcuts. Dark-first, arrow-key navigable, and mounted in a mock admin shell so you can see it in context.

Published

Minimal CSS Search Bar with Animated Underline — preview
06 / 36Pure CSS

Minimal CSS Search Bar with Animated Underline

A borderless, editorial search field: no box, no shadow, just type on a hairline that draws itself outward from the centre on focus. Two stacked rules — a static hairline and an accent line scaled with transform: scaleX() — give a 60fps underline with zero layout cost.

PublishedUpdated

CSS Rounded Pill Search Bar with Submit Button — preview
07 / 36Pure CSS

CSS Rounded Pill Search Bar with Submit Button

A fully-rounded pill with the magnifier inside on the left and a filled submit button hugging the right edge — the iOS/Safari address-bar shape. The button reveals its "Search" label only when the pill has focus, so the resting state stays compact.

PublishedUpdated

Glassmorphism CSS Search Bar (Backdrop Blur) — preview
08 / 36Pure CSS

Glassmorphism CSS Search Bar (Backdrop Blur)

Frosted glass done properly: backdrop-filter: blur(20px) saturate(180%) over a slowly drifting colour field, a 1px inner highlight stroke that fakes the lit top edge of real glass, and a specular sheen that sweeps across on focus.

PublishedUpdated

Neon Glow CSS Search Bar (Cyberpunk) — preview
09 / 36Pure CSS

Neon Glow CSS Search Bar (Cyberpunk)

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.

PublishedUpdated

CSS Search Bar with Animated Caret Highlight — preview
10 / 36Light JS

CSS Search Bar with Animated Caret Highlight

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

CSS Search Bar with Voice Input Microphone Button — preview
11 / 36Light JS

CSS Search Bar with Voice Input Microphone Button

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.

PublishedUpdated

CSS Search Bar with Loading Spinner Indicator — preview
12 / 36Light JS

CSS Search Bar with Loading Spinner Indicator

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.

PublishedUpdated

CSS Search Bar with Clear Button (X on Type) — preview
13 / 36Light JS

CSS Search Bar with Clear Button (X on Type)

The clear × appears only once you have typed — and the appearing is done entirely in CSS with :not(:placeholder-shown), no input listener required. Five lines of JavaScript clear the value and hand focus back to the field, which is the part CSS cannot do.

PublishedUpdated

Animated Expanding CSS Search Bar on Focus — preview
14 / 36Pure CSS

Animated Expanding CSS Search Bar on Focus

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.

PublishedUpdated

CSS Search Bar with Autocomplete Suggestions Dropdown — preview
15 / 36Pure CSS

CSS Search Bar with Autocomplete Suggestions Dropdown

The plain, fast autocomplete: focus the field and five suggestions slide down under it, each with a category glyph and a keyboard-affordance chevron. No JavaScript — the panel is a :focus-within reveal, styled to sit flush with the input so the two read as one surface.

PublishedUpdated

CSS Search Bar with Keyboard Shortcut Hint (Cmd K / Ctrl K) — preview
16 / 36Light JS

CSS Search Bar with Keyboard Shortcut Hint (Cmd K / Ctrl K)

The documentation-site classic: a quiet search field with a &lt;kbd&gt; chip pinned inside the right edge, showing ⌘K on Mac and Ctrl K on Windows/Linux. Focus the field with the shortcut and the chip flips to an <kbd>esc</kbd> hint.

PublishedUpdated

CSS Search Bar with Filter Chip Tags — preview
17 / 36Light JS

CSS Search Bar with Filter Chip Tags

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.

PublishedUpdated

CSS Search Bar with Recent Searches Dropdown — preview
18 / 36Light JS

CSS Search Bar with Recent Searches Dropdown

Focus the field and your recent searches drop down — each with a clock glyph, a real &lt;time&gt; stamp and its own remove button, plus a "Clear all" action in the header. History persists in localStorage in ten lines.

PublishedUpdated

CSS Search Bar with Rotating Placeholder Text — preview
19 / 36Pure CSS

CSS Search Bar with Rotating Placeholder Text

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

CSS People Search Bar with Avatar Chips — preview
20 / 36Light JS

CSS People Search Bar with Avatar Chips

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.

PublishedUpdated

Neo-Brutalist CSS Search Bar with Offset Stamp — preview
21 / 36Pure CSS

Neo-Brutalist CSS Search Bar with Offset Stamp

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.

PublishedUpdated

Compact Toolbar CSS Search Bar (Docs / Wiki) — preview
22 / 36Pure CSS

Compact Toolbar CSS Search Bar (Docs / Wiki)

A 200px search sized for a documentation sidebar: small type, tight 36px height, a quiet border that only asserts itself on focus, and a version chip below. Built as part of a real nav so you can see the density it is designed for.

PublishedUpdated

Hero Section CSS Search Bar with CTA — preview
23 / 36Pure CSS

Hero Section CSS Search Bar with CTA

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.

PublishedUpdated

CSS Search Bar with Side Category Indicator — preview
24 / 36Pure CSS

CSS Search Bar with Side Category Indicator

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.

PublishedUpdated

Floating CSS Search Bar with Drop Shadow (Elevated) — preview
25 / 36Pure CSS

Floating CSS Search Bar with Drop Shadow (Elevated)

Elevation done like a designer, not a default: a four-layer shadow stack (contact, ambient, mid, far) that mimics real light falloff, plus a lift on hover and a deeper drop on focus. The same tokens give you a documented elevation scale you can reuse across a product.

PublishedUpdated

CSS Search + Filter Sidebar Combo Bar — preview
26 / 36Pure CSS

CSS Search + Filter Sidebar Combo Bar

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.

PublishedUpdated

CSS Search Bar with Inline Loading Progress Bar — preview
27 / 36Light JS

CSS Search Bar with Inline Loading Progress Bar

A hairline progress bar rides the field's bottom edge: an indeterminate sweep while the request is in flight, then a determinate fill to 100% and a fade-out. Two keyframes, one data-state, and a real role="progressbar" for assistive tech.

PublishedUpdated

CSS Search Bar with Dual-Tone Border Outline — preview
28 / 36Pure CSS

CSS Search Bar with Dual-Tone Border Outline

A cyan→magenta gradient border that stays crisp at any radius — built with the double-background background-clip technique (border-box gradient under a padding-box fill), then set spinning on focus by animating a registered &lt;angle&gt;.

PublishedUpdated

CSS Glitch Search Bar with RGB Split Effect — preview
29 / 36Pure CSS

CSS Glitch Search Bar with RGB Split Effect

Chromatic aberration on a search field: the label splits into red and cyan ghosts that drift a pixel or two at rest and tear into clipped slices on focus. Built from two ::before/::after copies driven by attr() content and clip-path keyframes.

PublishedUpdated

Mobile-First Compact CSS Search Bar — preview
30 / 36Pure CSS

Mobile-First Compact CSS Search Bar

Sized for thumbs: a 44×44 minimum target, 16px text (so iOS never zooms on focus), an inset pressed state, and an iOS-style Cancel link that slides in on focus. Includes env(safe-area-inset-*) padding for notched devices.

PublishedUpdated

CSS Search Bar with Focus Ring Bloom Animation — preview
31 / 36Pure CSS

CSS Search Bar with Focus Ring Bloom Animation

A focus indicator with a moment of delight and no accessibility cost: on focus a soft ring blooms outward once and settles into a persistent 4px halo. The persistent ring is what satisfies WCAG; the bloom is the 320ms that makes the interface feel alive.

PublishedUpdated

CSS Search Bar Combo with Scope Selector — preview
32 / 36Light JS

CSS Search Bar Combo with Scope Selector

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.

PublishedUpdated

CSS Search Bar with Inset Pressed 3D Effect — preview
33 / 36Pure CSS

CSS Search Bar with Inset Pressed 3D Effect

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.

PublishedUpdated

CSS Search Bar with Animated Border Trace — preview
34 / 36Pure CSS

CSS Search Bar with Animated Border Trace

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.

PublishedUpdated

Floating Card CSS Search Bar (Modal Style) — preview
35 / 36Light JS

Floating Card CSS Search Bar (Modal Style)

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 &lt;dialog&gt; handles focus trapping, Escape and the backdrop — the pattern behind Notion, Vercel and most editorial sites.

PublishedUpdated

Aurora Gradient CSS Search Bar — preview
36 / 36Pure CSS

Aurora Gradient CSS Search Bar

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 &lt;angle&gt; so a conic gradient can actually animate — the technique that makes this look impossible in plain CSS.

PublishedUpdated

FAQ

Frequently asked questions

How do I build a Cmd+K command palette search bar in CSS?
Use the native 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 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
    with
  • 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 inside a
with a real (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 associated with inside a 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 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…