36 CSS Search Bars
07 / 36

All 36 in 36 CSS Search Bars

  1. 01Command Palette Cmd+K Search Bar
  2. 02Algolia-Style Instant Search with Highlighted Results Dropdown
  3. 03E-Commerce Product Search Bar with Category Scope Dropdown
  4. 04Header Navbar Integrated Sticky Search Bar
  5. 05SaaS Dashboard Command Search with Recent and Suggested
  6. 06Minimal CSS Search Bar with Animated Underline
  7. 07CSS Rounded Pill Search Bar with Submit Button
  8. 08Glassmorphism CSS Search Bar (Backdrop Blur)
  9. 09Neon Glow CSS Search Bar (Cyberpunk)
  10. 10CSS Search Bar with Animated Caret Highlight
  11. 11CSS Search Bar with Voice Input Microphone Button
  12. 12CSS Search Bar with Loading Spinner Indicator
  13. 13CSS Search Bar with Clear Button (X on Type)
  14. 14Animated Expanding CSS Search Bar on Focus
  15. 15CSS Search Bar with Autocomplete Suggestions Dropdown
  16. 16CSS Search Bar with Keyboard Shortcut Hint (Cmd K / Ctrl K)
  17. 17CSS Search Bar with Filter Chip Tags
  18. 18CSS Search Bar with Recent Searches Dropdown
  19. 19CSS Search Bar with Rotating Placeholder Text
  20. 20CSS People Search Bar with Avatar Chips
  21. 21Neo-Brutalist CSS Search Bar with Offset Stamp
  22. 22Compact Toolbar CSS Search Bar (Docs / Wiki)
  23. 23Hero Section CSS Search Bar with CTA
  24. 24CSS Search Bar with Side Category Indicator
  25. 25Floating CSS Search Bar with Drop Shadow (Elevated)
  26. 26CSS Search + Filter Sidebar Combo Bar
  27. 27CSS Search Bar with Inline Loading Progress Bar
  28. 28CSS Search Bar with Dual-Tone Border Outline
  29. 29CSS Glitch Search Bar with RGB Split Effect
  30. 30Mobile-First Compact CSS Search Bar
  31. 31CSS Search Bar with Focus Ring Bloom Animation
  32. 32CSS Search Bar Combo with Scope Selector
  33. 33CSS Search Bar with Inset Pressed 3D Effect
  34. 34CSS Search Bar with Animated Border Trace
  35. 35Floating Card CSS Search Bar (Modal Style)
  36. 36Aurora Gradient CSS Search Bar
Pure CSSMIT licensed

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.

Live Demo
Try it

Nucleo: 44,000+ SVG icons in five families · All Icons Bundle $149

Nucleo · Affiliate link

Get the Nucleo bundle

The code

<div class="sb-07">
  <button class="sb-07__theme" type="button" aria-pressed="false" aria-label="Switch to dark theme">
    <svg class="sb-07__moon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M20 14.2A8.2 8.2 0 0 1 9.8 4 8.4 8.4 0 1 0 20 14.2"/></svg>
    <svg class="sb-07__sun" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><circle cx="12" cy="12" r="4"/><path d="M12 3.4v2M12 18.6v2M3.4 12h2M18.6 12h2M6 6l1.4 1.4M16.6 16.6 18 18M18 6l-1.4 1.4M7.4 16.6 6 18"/></svg>
  </button>
  <div class="sb-07__stage">
    <div class="sb-07__bar" role="search">
      <svg class="sb-07__ico" viewBox="0 0 24 24" fill="none" aria-hidden="true" focusable="false"><circle cx="11" cy="11" r="6.4" stroke="currentColor" stroke-width="1.8"/><path d="m16 16 4.2 4.2" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg>
      <label class="sb-07__vh" for="sb-07-input">Search articles and guides</label>
      <input class="sb-07__input" id="sb-07-input" type="search" placeholder="Search articles, guides, changelog" autocomplete="off">
      <button class="sb-07__submit" type="button">
        <span class="sb-07__label"><span>Search</span></span>
        <svg viewBox="0 0 24 24" fill="none" aria-hidden="true" focusable="false"><path d="M5 12h13m-5.5-5.5L18 12l-5.5 5.5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>
      </button>
    </div>
  </div>
</div>
.sb-07 {
  --bg: #f2f4f7;
  --card: #ffffff;
  --ink: #0f1729;
  --muted: #697586;
  --line: #e3e8ef;
  --acc: #111827;
  --acc-ink: #ffffff;
  --ring: #2563eb;
  --h: 52px;
  --shadow: rgba(15,23,41,.16);
  width: 100%;
  min-height: 100vh;
  min-height: 100svh;
  display: block;
  box-sizing: border-box;
  font-family: system-ui,-apple-system,"Segoe UI",sans-serif;
  color: var(--ink);
  background: radial-gradient(40rem 22rem at 50% 0%, #ffffff, var(--bg) 70%);
  -webkit-font-smoothing: antialiased;
}

.sb-07 *,
.sb-07 *::before,
.sb-07 *::after {
  box-sizing: border-box;
}

.sb-07__stage {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: clamp(1rem,4vw,3rem);
}

.sb-07__vh {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.sb-07__bar {
  display: flex;
  align-items: center;
  gap: .6rem;
  inline-size: min(30rem,100%);
  min-block-size: max(48px,var(--h));
  padding-inline: 1.1rem .28rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  box-shadow: 0 1px 2px rgba(15,23,41,.05);
  transition: box-shadow .22s, border-color .22s, translate .22s;
}

.sb-07__bar:hover {
  box-shadow: 0 6px 18px -10px var(--shadow);
}

.sb-07__bar:focus-within {
  border-color: var(--acc);
  box-shadow: 0 10px 26px -14px var(--shadow), 0 0 0 4px rgba(37,99,235,.16);
  translate: 0 -1px;
}

.sb-07__ico {
  inline-size: 19px;
  block-size: 19px;
  flex: none;
  color: var(--muted);
}

.sb-07__input {
  flex: 1;
  min-inline-size: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: 400 .96rem/1 inherit;
}

.sb-07__input::placeholder {
  color: var(--muted);
}

.sb-07__input:focus {
  outline: none;
}

.sb-07__input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.sb-07__submit {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  flex: none;
  min-block-size: calc(max(48px,var(--h)) - 10px);
  padding-inline: .85rem;
  border: 0;
  border-radius: 999px;
  background: var(--acc);
  color: var(--acc-ink);
  cursor: pointer;
  font: 600 .87rem/1 inherit;
  transition: filter .18s, scale .12s;
}

.sb-07__submit:hover {
  filter: brightness(1.25);
}

.sb-07__submit:active {
  scale: .96;
}

.sb-07__submit:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 3px;
}

.sb-07__submit svg {
  inline-size: 17px;
  block-size: 17px;
}

.sb-07__label {
  display: grid;
  grid-template-columns: 0fr;
  transition: grid-template-columns .28s cubic-bezier(.2,.9,.25,1);
}

.sb-07__label > span {
  min-inline-size: 0;
  overflow: hidden;
  white-space: nowrap;
}

.sb-07__bar:focus-within .sb-07__label,
.sb-07__bar:hover .sb-07__label {
  grid-template-columns: 1fr;
}

.sb-07[data-theme="dark"] {
  --bg: #0b0f17;
  --card: #121826;
  --ink: #eef2f8;
  --muted: #8b95a7;
  --line: #212a3a;
  --acc: #f1f5f9;
  --acc-ink: #0b0f17;
  --ring: #7aa2ff;
  --shadow: rgba(0,0,0,.7);
  background: radial-gradient(40rem 22rem at 50% 0%, #141b2a, var(--bg) 70%);
}

@media (prefers-color-scheme: dark) {
  .sb-07:not([data-theme="light"]) {
    --bg: #0b0f17;
    --card: #121826;
    --ink: #eef2f8;
    --muted: #8b95a7;
    --line: #212a3a;
    --acc: #f1f5f9;
    --acc-ink: #0b0f17;
    --ring: #7aa2ff;
    --shadow: rgba(0,0,0,.7);
    background: radial-gradient(40rem 22rem at 50% 0%, #141b2a, var(--bg) 70%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .sb-07 *,
    .sb-07 *::before,
    .sb-07 *::after {
    transition: none !important;
    animation: none !important;
  }
}

@media (forced-colors: active) {
  .sb-07__bar,
    .sb-07__submit {
    border: 1px solid CanvasText;
  }
}

.sb-07__theme {
  position: absolute;
  inset-block-start: clamp(.75rem,2vw,1.25rem);
  inset-inline-end: clamp(.75rem,2vw,1.25rem);
  z-index: 50;
  inline-size: 2.5rem;
  block-size: 2.5rem;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,.12);
  color: currentColor;
  background: rgba(255,255,255,.72);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: background .25s ease, transform .25s cubic-bezier(.16,1,.3,1), border-color .25s ease;
}

.sb-07[data-theme="dark"] .sb-07__theme {
  background: rgba(20,20,28,.72);
  border-color: rgba(255,255,255,.15);
  color: #fff;
}

@media (prefers-color-scheme: dark) {
  .sb-07:not([data-theme="light"]) .sb-07__theme {
    background: rgba(20,20,28,.72);
    border-color: rgba(255,255,255,.15);
    color: #fff;
  }
}

.sb-07__theme:hover {
  transform: translateY(-1px);
  border-color: rgba(0,0,0,.24);
}

.sb-07[data-theme="dark"] .sb-07__theme:hover,
.sb-07:not([data-theme="light"]) .sb-07__theme:hover {
  border-color: rgba(255,255,255,.3);
}

.sb-07__theme:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

.sb-07__theme svg {
  grid-area: 1/1;
  inline-size: 1.1rem;
  block-size: 1.1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sb-07__sun {
  display: none;
}

.sb-07__theme[aria-pressed="true"] .sb-07__sun {
  display: block;
}

.sb-07__theme[aria-pressed="true"] .sb-07__moon {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .sb-07__theme {
    transition: none;
  }

  .sb-07__theme:hover {
    transform: none;
  }
}
(()=>{const r=document.querySelector('.sb-07');if(!r)return;const t=r.querySelector('.sb-07__theme');if(!t)return;const dark=()=>(r.dataset.theme||(matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light'))==='dark';const sync=()=>{t.setAttribute('aria-pressed',String(dark()));t.setAttribute('aria-label',dark()?'Switch to light theme':'Switch to dark theme');};t.addEventListener('click',()=>{r.dataset.theme=dark()?'light':'dark';sync();});matchMedia('(prefers-color-scheme: dark)').addEventListener('change',()=>{if(!r.dataset.theme)sync();});sync();})();
Paste this into ChatGPT, Claude, Cursor, or any coding assistant. The block below is pre-framed with everything the AI needs to integrate this demo into your project — markup, styles, scoping notes, and the source URL. Hit Copy and paste straight into your chat.
Here's a working CSS Search Bar from CodeFronts. Use it as-is or adapt to your framework. All classes are scoped under a unique prefix so the code won't collide with your existing styles. MIT licensed.
Demo: CSS Rounded Pill Search Bar with Submit Button
Source: https://codefronts.com/components/css-search-boxes/pill-with-submit/

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.
## HTML
```html
<div class="sb-07">
  <button class="sb-07__theme" type="button" aria-pressed="false" aria-label="Switch to dark theme">
    <svg class="sb-07__moon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M20 14.2A8.2 8.2 0 0 1 9.8 4 8.4 8.4 0 1 0 20 14.2"/></svg>
    <svg class="sb-07__sun" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><circle cx="12" cy="12" r="4"/><path d="M12 3.4v2M12 18.6v2M3.4 12h2M18.6 12h2M6 6l1.4 1.4M16.6 16.6 18 18M18 6l-1.4 1.4M7.4 16.6 6 18"/></svg>
  </button>
  <div class="sb-07__stage">
    <div class="sb-07__bar" role="search">
      <svg class="sb-07__ico" viewBox="0 0 24 24" fill="none" aria-hidden="true" focusable="false"><circle cx="11" cy="11" r="6.4" stroke="currentColor" stroke-width="1.8"/><path d="m16 16 4.2 4.2" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg>
      <label class="sb-07__vh" for="sb-07-input">Search articles and guides</label>
      <input class="sb-07__input" id="sb-07-input" type="search" placeholder="Search articles, guides, changelog" autocomplete="off">
      <button class="sb-07__submit" type="button">
        <span class="sb-07__label"><span>Search</span></span>
        <svg viewBox="0 0 24 24" fill="none" aria-hidden="true" focusable="false"><path d="M5 12h13m-5.5-5.5L18 12l-5.5 5.5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>
      </button>
    </div>
  </div>
</div>
```
## CSS
```css
.sb-07 {
  --bg: #f2f4f7;
  --card: #ffffff;
  --ink: #0f1729;
  --muted: #697586;
  --line: #e3e8ef;
  --acc: #111827;
  --acc-ink: #ffffff;
  --ring: #2563eb;
  --h: 52px;
  --shadow: rgba(15,23,41,.16);
  width: 100%;
  min-height: 100vh;
  min-height: 100svh;
  display: block;
  box-sizing: border-box;
  font-family: system-ui,-apple-system,"Segoe UI",sans-serif;
  color: var(--ink);
  background: radial-gradient(40rem 22rem at 50% 0%, #ffffff, var(--bg) 70%);
  -webkit-font-smoothing: antialiased;
}

.sb-07 *,
.sb-07 *::before,
.sb-07 *::after {
  box-sizing: border-box;
}

.sb-07__stage {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: clamp(1rem,4vw,3rem);
}

.sb-07__vh {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.sb-07__bar {
  display: flex;
  align-items: center;
  gap: .6rem;
  inline-size: min(30rem,100%);
  min-block-size: max(48px,var(--h));
  padding-inline: 1.1rem .28rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  box-shadow: 0 1px 2px rgba(15,23,41,.05);
  transition: box-shadow .22s, border-color .22s, translate .22s;
}

.sb-07__bar:hover {
  box-shadow: 0 6px 18px -10px var(--shadow);
}

.sb-07__bar:focus-within {
  border-color: var(--acc);
  box-shadow: 0 10px 26px -14px var(--shadow), 0 0 0 4px rgba(37,99,235,.16);
  translate: 0 -1px;
}

.sb-07__ico {
  inline-size: 19px;
  block-size: 19px;
  flex: none;
  color: var(--muted);
}

.sb-07__input {
  flex: 1;
  min-inline-size: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: 400 .96rem/1 inherit;
}

.sb-07__input::placeholder {
  color: var(--muted);
}

.sb-07__input:focus {
  outline: none;
}

.sb-07__input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.sb-07__submit {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  flex: none;
  min-block-size: calc(max(48px,var(--h)) - 10px);
  padding-inline: .85rem;
  border: 0;
  border-radius: 999px;
  background: var(--acc);
  color: var(--acc-ink);
  cursor: pointer;
  font: 600 .87rem/1 inherit;
  transition: filter .18s, scale .12s;
}

.sb-07__submit:hover {
  filter: brightness(1.25);
}

.sb-07__submit:active {
  scale: .96;
}

.sb-07__submit:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 3px;
}

.sb-07__submit svg {
  inline-size: 17px;
  block-size: 17px;
}

.sb-07__label {
  display: grid;
  grid-template-columns: 0fr;
  transition: grid-template-columns .28s cubic-bezier(.2,.9,.25,1);
}

.sb-07__label > span {
  min-inline-size: 0;
  overflow: hidden;
  white-space: nowrap;
}

.sb-07__bar:focus-within .sb-07__label,
.sb-07__bar:hover .sb-07__label {
  grid-template-columns: 1fr;
}

.sb-07[data-theme="dark"] {
  --bg: #0b0f17;
  --card: #121826;
  --ink: #eef2f8;
  --muted: #8b95a7;
  --line: #212a3a;
  --acc: #f1f5f9;
  --acc-ink: #0b0f17;
  --ring: #7aa2ff;
  --shadow: rgba(0,0,0,.7);
  background: radial-gradient(40rem 22rem at 50% 0%, #141b2a, var(--bg) 70%);
}

@media (prefers-color-scheme: dark) {
  .sb-07:not([data-theme="light"]) {
    --bg: #0b0f17;
    --card: #121826;
    --ink: #eef2f8;
    --muted: #8b95a7;
    --line: #212a3a;
    --acc: #f1f5f9;
    --acc-ink: #0b0f17;
    --ring: #7aa2ff;
    --shadow: rgba(0,0,0,.7);
    background: radial-gradient(40rem 22rem at 50% 0%, #141b2a, var(--bg) 70%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .sb-07 *,
    .sb-07 *::before,
    .sb-07 *::after {
    transition: none !important;
    animation: none !important;
  }
}

@media (forced-colors: active) {
  .sb-07__bar,
    .sb-07__submit {
    border: 1px solid CanvasText;
  }
}

.sb-07__theme {
  position: absolute;
  inset-block-start: clamp(.75rem,2vw,1.25rem);
  inset-inline-end: clamp(.75rem,2vw,1.25rem);
  z-index: 50;
  inline-size: 2.5rem;
  block-size: 2.5rem;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,.12);
  color: currentColor;
  background: rgba(255,255,255,.72);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: background .25s ease, transform .25s cubic-bezier(.16,1,.3,1), border-color .25s ease;
}

.sb-07[data-theme="dark"] .sb-07__theme {
  background: rgba(20,20,28,.72);
  border-color: rgba(255,255,255,.15);
  color: #fff;
}

@media (prefers-color-scheme: dark) {
  .sb-07:not([data-theme="light"]) .sb-07__theme {
    background: rgba(20,20,28,.72);
    border-color: rgba(255,255,255,.15);
    color: #fff;
  }
}

.sb-07__theme:hover {
  transform: translateY(-1px);
  border-color: rgba(0,0,0,.24);
}

.sb-07[data-theme="dark"] .sb-07__theme:hover,
.sb-07:not([data-theme="light"]) .sb-07__theme:hover {
  border-color: rgba(255,255,255,.3);
}

.sb-07__theme:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

.sb-07__theme svg {
  grid-area: 1/1;
  inline-size: 1.1rem;
  block-size: 1.1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sb-07__sun {
  display: none;
}

.sb-07__theme[aria-pressed="true"] .sb-07__sun {
  display: block;
}

.sb-07__theme[aria-pressed="true"] .sb-07__moon {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .sb-07__theme {
    transition: none;
  }

  .sb-07__theme:hover {
    transform: none;
  }
}
```

## JavaScript
```js
(()=>{const r=document.querySelector('.sb-07');if(!r)return;const t=r.querySelector('.sb-07__theme');if(!t)return;const dark=()=>(r.dataset.theme||(matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light'))==='dark';const sync=()=>{t.setAttribute('aria-pressed',String(dark()));t.setAttribute('aria-label',dark()?'Switch to light theme':'Switch to dark theme');};t.addEventListener('click',()=>{r.dataset.theme=dark()?'light':'dark';sync();});matchMedia('(prefers-color-scheme: dark)').addEventListener('change',()=>{if(!r.dataset.theme)sync();});sync();})();
```

How this works

Animating to auto width, correctly. You cannot transition width:auto, but you can transition a grid track between 0fr and 1fr. The label sits in that track with min-inline-size:0; overflow:hidden:

.sb-07__label{display:grid; grid-template-columns:0fr; transition:grid-template-columns .28s;}
.sb-07__label > span{min-inline-size:0; overflow:hidden; white-space:nowrap;}
.sb-07__bar:focus-within .sb-07__label{grid-template-columns:1fr;}

This is the modern replacement for max-width: 0 → 200px hacks: the track resolves to the content's real width, so nothing is clipped and nothing over-shoots.

Keeping the pill a pill. The submit button is a normal flex child with margin:4px and its own border-radius:999px. Positioning it absolutely instead is the common mistake — the input then needs manual right padding, which breaks the second the label grows.

Make it yours

  • Resize everything from --h (the pill height, 52px here): padding, button size and radius are all derived from it.
  • For an always-labelled button, delete the 0fr rule and set the track to 1fr.
  • Ghost variant: swap the button background for transparent and add box-shadow:inset 0 0 0 1px var(--acc).
  • Full-width hero usage: change inline-size:min(30rem,100%) to 100% and raise --h to 60px.

Gotchas — read before shipping

  • A pill-shaped focus ring must be pill-shaped too — outline follows border-radius in current browsers, but only if the outline is on the rounded element itself, not a square parent.
  • Chromium's native clear button on type="search" lands right where an inset button sits; this demo hides it with ::-webkit-search-cancel-button{appearance:none} since the submit button owns that corner.
  • Do not put the icon inside the input's padding-inline-start as a background image — it cannot inherit currentColor and it disappears in forced-colors mode.
  • Keep the button ≥44px tall even when the pill shrinks on mobile; the demo clamps --h at 48px minimum.

Browser support

ChromeSafariFirefoxEdge
107+16+66+107+

Animating grid-template-columns between 0fr and 1fr is Chrome 107 / Safari 16 / Firefox 66; older browsers simply show the label without the slide. Everything else (flexbox, border-radius, :focus-within) is universal. color-mix() has a hex fallback declared first.

Techniques used in this demo

Search CodeFronts

Loading…