Skip to content

Dual price range slider in HTML and CSS

A two-handle slider to pick a price range, synced with two number fields and filtering the list live.

Here is an excerpt of this component's code in HTML and CSS. The full code is free for members, ready to copy into your project.

This component also comes in

Open in a new tab

The code in HTML and CSS

index.html
<!doctype html>
<html lang="fr">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Curseur double pour fourchette de prix</title>
    <link rel="stylesheet" href="style.css" />
  </head>
  <body>
    <main class="demo">
      <section class="cdp" data-cdp aria-labelledby="cdp-titre">
        <h2 class="cdp-title" id="cdp-titre">Mobilier vintage</h2>
script.js
document.querySelectorAll("[data-cdp]").forEach((root) => {
  const on = (el, type, fn) => el.addEventListener(type, fn);
  const ranges = { lo: root.querySelector('[data-cdp-range="lo"]'), hi: root.querySelector('[data-cdp-range="hi"]') };
  const numbers = { lo: root.querySelector('[data-cdp-number="lo"]'), hi: root.querySelector('[data-cdp-number="hi"]') };
  const slider = root.querySelector("[data-cdp-slider]");
  const items = [...root.querySelectorAll("[data-cdp-price]")];
  const min = Number(ranges.lo.min);
  const max = Number(ranges.lo.max);
  const step = Number(ranges.lo.step);

  const apply = (side, raw) => {
    const other = Number(ranges[side === "lo" ? "hi" : "lo"].value);
style.css
:root {
  --cdp-card: #ffffff;
  --cdp-text: #2a2017;
  --cdp-muted: #5c4e40;
  --cdp-line: #d8cdbf;
  --cdp-field: #ffffff;
  --cdp-track: #ece4d9;
  --cdp-thumb: #b45309;
  --cdp-thumb-ring: #ffffff;
  --demo-bg: #f2ece4;
  --demo-text: #2a2017;
}

Free component: copy it freely, including for commercial projects.

Forms and inputs components in HTML and CSS
  • A quote request form for tradespeople: the customer describes the work, picks a start date range and attaches up to six site photos, each with a preview, its size and a button to remove it.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A quote request form whose labels, hints and error messages are full French sentences, still readable at 320 px: nothing overflows, nothing is cut off, and each error is tied to its field.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • Visitors pick a package and tick options: the pre-tax total, VAT and total including tax update live, and the summary is sent with the contact form.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A short NPS survey: a 0 to 10 score as radio buttons, then a follow-up question adapted to whether the customer is a detractor, passive or promoter.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • An honest unsubscribe page: address prefilled from the link, choice between stopping everything or receiving less, optional reason and an undo.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A callback request form: French phone number checked and formatted, topic, working day and time slot, with explicit consent to the call.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component