CSS Price Range Slider

A dual-handle price filter built from two stacked range inputs where only the thumbs catch the pointer.

  • dual range
  • min max
  • price filter
  • two thumbs
  • slider
  • ecommerce
HTML
<fieldset class="price-range">
  <legend>Price</legend>
  <div class="price-range-track">
    <input type="range" min="0" max="500" step="10" value="80" aria-label="Minimum price">
    <input type="range" min="0" max="500" step="10" value="360" aria-label="Maximum price">
  </div>
  <p><span>$0</span><span>$500</span></p>
</fieldset>
CSS
.price-range {
  --thumb: 20px;
  width: 260px;
  margin: 0;
  padding: 0;
  border: 0;
  color: #4a044e;
  font-family: system-ui, sans-serif;
}

.price-range legend {
  margin-bottom: 8px;
  padding: 0;
  font-size: 14px;
  font-weight: 700;
}

.price-range-track {
  position: relative;
  height: var(--thumb);
}

.price-range-track::before {
  content: "";
  position: absolute;
  top: 50%;
  right: calc(var(--thumb) / 2);
  left: calc(var(--thumb) / 2);
  height: 4px;
  border-radius: 999px;
  background: #f5d0fe;
  transform: translateY(-50%);
}

.price-range input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: var(--thumb);
  margin: 0;
  background: none;
  -webkit-appearance: none;
  appearance: none;
  pointer-events: none;
}

.price-range input::-webkit-slider-thumb {
  width: var(--thumb);
  height: var(--thumb);
  border: 0;
  border-radius: 50%;
  background: #c026d3;
  box-shadow: 0 0 0 4px #fff, 0 2px 6px 4px rgba(112, 26, 117, 0.25);
  -webkit-appearance: none;
  appearance: none;
  pointer-events: auto;
  cursor: grab;
}

.price-range input::-moz-range-thumb {
  width: var(--thumb);
  height: var(--thumb);
  border: 0;
  border-radius: 50%;
  background: #c026d3;
  box-shadow: 0 0 0 4px #fff, 0 2px 6px 4px rgba(112, 26, 117, 0.25);
  pointer-events: auto;
  cursor: grab;
}

.price-range input:focus-visible {
  outline: none;
}

.price-range input:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px #fff, 0 0 0 6px #c026d3;
}

.price-range input:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 4px #fff, 0 0 0 6px #c026d3;
}

.price-range p {
  display: flex;
  justify-content: space-between;
  margin: 8px 0 0;
  color: #a21caf;
  font-size: 12px;
}

About this CSS Price Range Slider

This CSS Price Range Slider is 89 lines of pure CSS (1.7 KB) with no JavaScript and no dependencies. It uses transforms, box shadows, Flexbox and keyboard focus styles. It works in current versions of Chrome, Edge, Safari and Firefox. It works in any stack: plain HTML, React, Vue, Svelte, Astro, WordPress or Webflow.

CSS features used

Customize it

Change these custom properties to restyle the price range slider without touching the rest of the CSS:

PropertyDefault
--thumb20px

How to use this price range slider

  1. Copy the HTML and paste it where you want the element to appear.
  2. Copy the CSS into your stylesheet, or inside a <style> tag.
  3. Keep the .price-range class name, or rename it in both places. Then tweak colors, sizes and timing to match your design.
  4. Using React or Next.js? Change class to className in the HTML. The CSS works as is, including in Tailwind projects (put it in your global stylesheet).

Building with an AI tool?

“Copy for AI” copies a short prompt for Cursor, Claude Code, Lovable, Bolt or v0. Your AI tool opens the Markdown version of this snippet and reads the HTML, CSS and setup notes there. If your tool can't open links, with the code instead. More ways to use copy CSS with AI.

Feedback