Skip to content

Price Range Filter

Bootstrap 6 shop price filter with minimum and maximum Range sliders, synced number inputs, a price histogram, quick-range chips and live product results.

Also known as: price slider filter, price range slider, min max price filter, product price filter, price histogram slider

Price Range Filter live demo

Open in new tab

Bootstrap 6 code (HTML, CSS, JS)

A shop sidebar price filter built with Bootstrap 6. Two Range sliders set the minimum and maximum, two number inputs with a "$" adornment stay in sync with them, and a small histogram shows how products spread across prices. Quick-range chips set common budgets in one click, and the product list next to the filter updates as you drag.

How it works

The filter is a form.prf-filter whose data-prf-min, data-prf-max and data-prf-gap define the price scale and the smallest allowed distance between the two handles. The sliders are Bootstrap 6 .form-range wrappers with theme-success. style.css brands that role teal by overriding --bs-success-base on .prf-root.

Everything goes through one apply(min, max) function. It writes both sliders and both .form-ghost number inputs, calls Range.getOrCreateInstance(...).update() so the track fill follows a programmatic change, and sets aria-valuetext. It then moves the teal band under the histogram through --prf-from and --prf-to, marks the bars inside the range with .prf-bar--in, shows or hides each .prf-item by its data-prf-price, updates the .prf-count status, and highlights a .prf-preset chip when the range matches it exactly.

When you drag the minimum slider into the maximum, it stops data-prf-gap below it (and the other way round), so the handles never cross. The number inputs are validated on change, not on every keystroke, so typing "150" is never clamped at "1". Values snap to steps of 5 and are clamped to the scale. At the top of the scale the maximum reads "$500+" and includes every price above it. The histogram bars come from the comma-separated counts in data-prf-histogram. "Clear" resets the form to the full range.

Customization

  • data-prf-min / data-prf-max on .prf-filter (plus the matching min/max on the inputs): change the price scale.
  • data-prf-gap on .prf-filter: the minimum distance between the two handles (10 by default).
  • data-prf-histogram on .prf-histogram: one product count per equal-width bucket. Generate it on the server from your catalogue.
  • data-prf-range="50-150" on each .prf-preset chip: the range it applies. Add or remove chips freely.
  • data-prf-price on each .prf-item: the price used for filtering. Replace the list loop with a fetch() to your search API.
  • --prf-accent and --prf-accent-soft on .prf-root: change the teal brand color of the sliders, band, chips and count.

Use cases

  • Online shops: minimum and maximum sliders filter products by price with live results
  • Marketplaces: a price histogram shows where most products sit in the range
  • Category pages: number inputs stay synced with the sliders for exact amounts
  • Quick filtering: preset range chips jump to common price brackets

Accessibility

Both sliders and both number inputs have visible labels and accept keyboard input. Sliders announce "$40" or "$500 or more" through aria-valuetext. The chips are toggle buttons with aria-pressed. The result count sits in a role="status" live region, so screen reader users hear "6 of 10 products" after each change. The histogram is decorative (aria-hidden), and its color transition stops under prefers-reduced-motion.

Bootstrap 6 notes

The Bootstrap 6 Range uses a .form-range wrapper around .form-range-input, which makes the filled track possible. The "$" prefix uses the new form-adorn with form-adorn-text and a borderless form-ghost input instead of an input-group-text. The quick ranges are Bootstrap 6 .chip elements with the active state. Built on 6.0.0-alpha.1, so the API can still change.

Price Range Filter at a glance

Framework
Bootstrap 6
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
Bootstrap 6, Bootstrap Icons
Layout
Responsive, works on mobile
Category
Range Sliders
License
Free for personal and commercial use

Questions about this template

Can I use the Price Range Filter code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

Load Bootstrap 6 and Bootstrap Icons from a CDN (the links are under Requirements). Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

Add these to your page (already included in the download):

  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@6.0.0-alpha.1/dist/css/bootstrap.min.css">
  • <script type="module" src="https://cdn.jsdelivr.net/npm/bootstrap@6.0.0-alpha.1/dist/js/bootstrap.bundle.min.js"></script>
  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">

Built for Bootstrap 6.0.0-alpha.1. Bootstrap 6 ships as an ES module, so its script and this component's JavaScript load with type="module". Alpha releases can still change before the stable version.

Price Range Filter – free Bootstrap 6 range slider template
Price Range Filter · free Bootstrap 6 range slider template

More Range Sliders

Custom Range Slider – free Pure CSS range slider template

Custom Range Slider

Styled range input with a gradient fill, ring thumb and a live value bubble that follows the handle, in pure CSS and a few lines of vanilla JS.

Range Slider with Value – free Bootstrap 6 range slider template

Range Slider with Value

Dark Bootstrap 6 photo adjustment panel with Range sliders, live output values, a value bubble, tick marks, step buttons and a filtered live preview.

Dual Range Price Slider – free Tailwind CSS range slider template

Dual Range Price Slider

Tailwind CSS min/max price slider with two handles, synced number inputs and a live histogram that counts products in the selected range.