#118
ui
light
mobile: high
Search & Filtering
Visual Range Histogram Slider Filter
Dual-handle price range slider overlaid directly on a live distribution histogram that filters listings in real time.
Inspired by Turo ↗
WHY THIS AESTHETIC IS UNIQUE
Eliminates blind min/max guessing by showing exactly where inventory clusters before the user drags a single handle.
BEST FOR
Car & travel rental searchReal estate price filtersFlight & hotel aggregatorsE-commerce spec filters
TAGS
COLOR PALETTE (CLICK TO COPY HEX)
TYPOGRAPHY
- Display
- Plus Jakarta Sans
- Body
- Inter
- Mono
- JetBrains Mono
- Scale
- Tabular mono price readouts ($45 — $165/day) paired with crisp 15px vehicle titles and spec chips.
ARCHITECTURE & MOBILE NOTES
LAYOUT
Top filter card housing the 20-bar distribution histogram + dual-handle slider + synchronized numeric inputs, followed by a responsive vehicle card grid.
INTERACTION
Dragging either handle highlights in-range histogram bars in accent violet, dims out-of-range bars, prevents handle crossover, and live-filters matching cards with an instant reset pill.
MOBILE
Oversized 44px touch hit-zones around both slider thumbs ensure effortless dragging on 390px screens without fighting scroll.
AI AGENT GUARDRAILS
DO
- Enforce a minimum separation gap so min and max handles never overlap into an ungrabbable stack
- Pair the visual slider with synchronized min/max readouts and keyboard arrow support on both thumbs
- Show the exact matching listing count and average price dynamically as the user drags
DON'T
- Do not render a decorative static histogram that ignores the actual underlying dataset distribution
- Do not force users to hit a separate Apply button when filtering a local client-side dataset
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>DriveGrid — Visual Range Histogram Filter</title>
<style>
:root {
--canvas: #F9F8F6;
--surface: #FFFFFF;
--ink: #18181B;
--accent: #593CFB;
--accent-soft: #F3F0FF;
--muted: #71717A;
--border: #E5E4E0;
--bar-off: #E4E4E7;
--font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
body {
background: var(--canvas);
color: var(--ink);
font-family: var(--font);
min-height: 100dvh;
overflow-x: hidden;
}
.page {
max-width: 1120px;
margin: 0 auto;
padding: 18px 14px 64px;
}
@media (min-width: 760px) {
.page { padding: 30px 28px 80px; }
}
.header {
display: flex;
flex-wrap: wrap;
align-items: flex-end;
justify-content: space-between;
gap: 12px;
margin-bottom: 18px;
}
.header h1 {
font-size: 25px;
font-weight: 800;
letter-spacing: -0.025em;
}
.header p {
font-size: 13px;
color: var(--muted);
margin-top: 2px;
}
.trip-badge {
font-size: 12px;
font-weight: 650;
color: var(--ink);
background: var(--surface);
border: 1px solid var(--border);
padding: 8px 13px;
border-radius: 999px;
}
/* Histogram Filter Card */
.filter-card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 20px;
padding: 18px 18px 16px;
box-shadow: 0 10px 28px rgba(24, 24, 27, 0.05);
margin-bottom: 22px;
}
.filter-top {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 10px;
margin-bottom: 14px;
}
.price-summary {
display: flex;
align-items: baseline;
gap: 10px;
flex-wrap: wrap;
}
.range-readout {
font-size: 20px;
font-weight: 800;
color: var(--ink);
letter-spacing: -0.02em;
}
.range-readout span { color: var(--accent); }
.avg-readout {
font-size: 12px;
font-weight: 600;
color: var(--muted);
}
.filter-actions {
display: flex;
align-items: center;
gap: 8px;
}
.cat-strip {
display: flex;
gap: 6px;
flex-wrap: wrap;
}
.cat-btn {
min-height: 44px;
padding: 0 13px;
border-radius: 10px;
border: 1px solid var(--border);
background: var(--canvas);
color: var(--muted);
font-size: 12px;
font-weight: 650;
cursor: pointer;
transition: all 0.14s;
}
.cat-btn[aria-pressed="true"] {
background: var(--accent-soft);
color: var(--accent);
border-color: rgba(89, 60, 251, 0.45);
}
.reset-btn {
min-height: 44px;
padding: 0 14px;
border-radius: 10px;
border: 1px solid var(--border);
background: var(--surface);
color: var(--ink);
font-size: 12px;
font-weight: 650;
cursor: pointer;
}
.reset-btn:hover { border-color: var(--accent); color: var(--accent); }
/* Histogram + Overlaid Dual-Handle Slider */
.hist-slider-box {
position: relative;
padding: 8px 14px 26px;
user-select: none;
-webkit-user-select: none;
}
.bars {
height: 92px;
display: grid;
grid-template-columns: repeat(20, 1fr);
align-items: end;
gap: 4px;
padding-bottom: 2px;
}
.bar {
border-radius: 4px 4px 1px 1px;
background: var(--bar-off);
transition: background 0.14s, transform 0.14s;
min-height: 6px;
}
.bar.in-range {
background: var(--accent);
}
.track-wrap {
position: relative;
height: 24px;
display: flex;
align-items: center;
touch-action: none;
}
.track-bg {
position: absolute;
left: 0;
right: 0;
height: 4px;
border-radius: 999px;
background: var(--bar-off);
}
.track-fill {
position: absolute;
height: 4px;
border-radius: 999px;
background: var(--accent);
}
.thumb {
position: absolute;
top: 50%;
width: 28px;
height: 28px;
margin-left: -14px;
transform: translateY(-50%);
border-radius: 50%;
background: #FFFFFF;
border: 2.5px solid var(--accent);
box-shadow: 0 4px 12px rgba(89, 60, 251, 0.28);
cursor: grab;
touch-action: none;
z-index: 3;
transition: transform 0.1s, box-shadow 0.1s;
}
/* Invisible 44px touch halo */
.thumb::after {
content: "";
position: absolute;
inset: -10px;
}
.thumb:hover, .thumb:focus-visible {
outline: none;
box-shadow: 0 0 0 5px rgba(89, 60, 251, 0.2);
}
.thumb.active {
cursor: grabbing;
transform: translateY(-50%) scale(1.12);
z-index: 4;
}
.scale-labels {
display: flex;
justify-content: space-between;
font-size: 11px;
font-weight: 600;
color: var(--muted);
margin-top: 6px;
}
/* Results bar */
.results-bar {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 12px;
padding: 0 2px;
font-size: 13px;
color: var(--muted);
}
.results-bar strong { color: var(--ink); }
/* Vehicle Grid */
.car-grid {
display: grid;
grid-template-columns: 1fr;
gap: 14px;
}
@media (min-width: 640px) {
.car-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 980px) {
.car-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.car-card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 16px;
overflow: hidden;
display: flex;
flex-direction: column;
transition: transform 0.16s, box-shadow 0.16s;
}
.car-card:hover {
transform: translateY(-2px);
box-shadow: 0 12px 26px rgba(24, 24, 27, 0.08);
}
.car-visual {
height: 128px;
width: 100%;
display: block;
}
.car-body {
padding: 13px 15px 15px;
display: flex;
flex-direction: column;
gap: 6px;
flex: 1;
}
.car-head {
display: flex;
justify-content: space-between;
align-items: flex-start;
gap: 8px;
}
.car-name {
font-size: 15px;
font-weight: 750;
color: var(--ink);
}
.car-rating {
font-size: 12px;
font-weight: 700;
color: var(--ink);
white-space: nowrap;
}
.car-rating span { color: var(--accent); }
.car-specs {
font-size: 12px;
color: var(--muted);
}
.car-footer {
margin-top: auto;
padding-top: 10px;
border-top: 1px solid #F4F4F5;
display: flex;
justify-content: space-between;
align-items: baseline;
}
.car-tag {
font-size: 11px;
font-weight: 700;
padding: 3px 8px;
border-radius: 6px;
background: var(--accent-soft);
color: var(--accent);
}
.car-price {
font-size: 17px;
font-weight: 800;
color: var(--ink);
}
.car-price small { font-size: 12px; font-weight: 500; color: var(--muted); }
.empty-box {
grid-column: 1 / -1;
text-align: center;
padding: 44px 16px;
background: var(--surface);
border: 1px dashed var(--border);
border-radius: 16px;
color: var(--muted);
}
</style>
</head>
<body>
<div class="page">
<header class="header">
<div>
<h1>San Francisco · Car Search</h1>
<p>Drag either price handle directly beneath the live distribution histogram</p>
</div>
<div class="trip-badge">Fri 10:00 AM → Sun 6:00 PM</div>
</header>
<section class="filter-card" aria-label="Daily Price Range Histogram Filter">
<div class="filter-top">
<div class="price-summary">
<div class="range-readout" id="rangeReadout"><span>$45</span> – <span>$215</span> / day</div>
<div class="avg-readout" id="avgReadout">Avg $118/day</div>
</div>
<div class="filter-actions">
<div class="cat-strip" role="group" aria-label="Vehicle type">
<button class="cat-btn" data-cat="all" aria-pressed="true">All</button>
<button class="cat-btn" data-cat="EV" aria-pressed="false">EV</button>
<button class="cat-btn" data-cat="SUV" aria-pressed="false">SUV</button>
<button class="cat-btn" data-cat="Sport" aria-pressed="false">Sport</button>
</div>
<button class="reset-btn" id="resetBtn">Reset</button>
</div>
</div>
<div class="hist-slider-box">
<div class="bars" id="histBars" aria-hidden="true"></div>
<div class="track-wrap" id="trackWrap">
<div class="track-bg"></div>
<div class="track-fill" id="trackFill"></div>
<div class="thumb" id="thumbMin" role="slider" tabindex="0" aria-label="Minimum daily price" aria-valuemin="35" aria-valuemax="245" aria-valuenow="45"></div>
<div class="thumb" id="thumbMax" role="slider" tabindex="0" aria-label="Maximum daily price" aria-valuemin="35" aria-valuemax="245" aria-valuenow="215"></div>
</div>
<div class="scale-labels">
<span>$35/day</span>
<span>$105</span>
<span>$175</span>
<span>$245+/day</span>
</div>
</div>
</section>
<div class="results-bar">
<span id="matchCount"><strong>12 vehicles</strong> available in range</span>
<span>Instant Book · Free Cancellation</span>
</div>
<main class="car-grid" id="carGrid"></main>
</div>
<script>
(() => {
const MIN_PRICE = 35;
const MAX_PRICE = 245;
const STEP = 5;
// 20-bin market distribution curve (simulated local fleet inventory density)
const BIN_COUNTS = [2, 4, 6, 9, 12, 15, 18, 16, 14, 13, 11, 9, 10, 8, 7, 5, 4, 3, 2, 2];
const VEHICLES = [
{ name: '2023 Honda Civic Hatch', cat: 'Compact', price: 48, rating: '4.94', trips: 112, specs: '36 MPG · Apple CarPlay · Mission Dist.', tint: ['#EEF2FF','#6366F1'] },
{ name: '2024 Hyundai Ioniq 5', cat: 'EV', price: 68, rating: '4.98', trips: 84, specs: '303 mi range · Fast Charge · SoMa', tint: ['#ECFEFF','#0891B2'] },
{ name: '2023 Subaru Outback AWD', cat: 'SUV', price: 76, rating: '4.91', trips: 147, specs: 'AWD · Roof Rack · Marina', tint: ['#ECFDF5','#059669'] },
{ name: '2024 Tesla Model 3 Highland', cat: 'EV', price: 84, rating: '4.97', trips: 203, specs: '341 mi range · Autopilot · Hayes Valley', tint: ['#F5F3FF','#7C3AED'] },
{ name: '2023 Mazda MX-5 Miata RF', cat: 'Sport', price: 96, rating: '4.99', trips: 61, specs: 'Retractable Hardtop · 6-Speed · Nob Hill', tint: ['#FFF1F2','#E11D48'] },
{ name: '2024 Volvo XC40 Recharge', cat: 'SUV', price: 108, rating: '4.95', trips: 53, specs: 'AWD EV · Panoramic Roof · Noe Valley', tint: ['#F0F9FF','#0284C7'] },
{ name: '2023 Polestar 2 Dual Motor', cat: 'EV', price: 115, rating: '4.96', trips: 79, specs: '408 hp · Pilot Pack · Dogpatch', tint: ['#F4F4F5','#52525B'] },
{ name: '2024 Rivian R1S Adventure', cat: 'SUV', price: 148, rating: '5.00', trips: 38, specs: '7 Seats · Quad-Motor · Presidio', tint: ['#FEFCE8','#CA8A04'] },
{ name: '2023 BMW M240i xDrive', cat: 'Sport', price: 162, rating: '4.93', trips: 45, specs: '382 hp · AWD Coupe · Embarcadero', tint: ['#EFF6FF','#2563EB'] },
{ name: '2024 Porsche Macan T', cat: 'SUV', price: 185, rating: '4.98', trips: 67, specs: 'Sport Chrono · PASM · Pacific Heights', tint: ['#FAF5FF','#9333EA'] },
{ name: '2023 Porsche Taycan 4S', cat: 'EV', price: 212, rating: '4.99', trips: 29, specs: '522 hp · 800V Fast Charge · FiDi', tint: ['#F0FDFA','#0D9488'] },
{ name: '2024 Porsche 911 Carrera', cat: 'Sport', price: 238, rating: '5.00', trips: 19, specs: 'PDK · Sport Exhaust · North Beach', tint: ['#FFF7ED','#EA580C'] }
];
let rangeMin = 45;
let rangeMax = 215;
let activeCat = 'all';
const histBarsEl = document.getElementById('histBars');
const trackWrap = document.getElementById('trackWrap');
const trackFill = document.getElementById('trackFill');
const thumbMin = document.getElementById('thumbMin');
const thumbMax = document.getElementById('thumbMax');
const rangeReadout = document.getElementById('rangeReadout');
const avgReadout = document.getElementById('avgReadout');
const matchCount = document.getElementById('matchCount');
const carGrid = document.getElementById('carGrid');
// Build 20 histogram bars
const maxBin = Math.max(...BIN_COUNTS);
const barEls = BIN_COUNTS.map((count, i) => {
const bar = document.createElement('div');
bar.className = 'bar';
bar.style.height = `${Math.max(10, Math.round((count / maxBin) * 100))}%`;
bar.dataset.bin = i;
histBarsEl.appendChild(bar);
return bar;
});
function carSvg([bg, accent], cat) {
const isSuv = cat === 'SUV';
const roof = isSuv
? 'M 66 76 L 90 46 L 194 46 L 216 76 Z'
: cat === 'Sport'
? 'M 74 78 L 108 54 L 184 54 L 214 78 Z'
: 'M 70 76 L 100 50 L 188 50 L 216 76 Z';
return `
<svg class="car-visual" viewBox="0 0 280 128" aria-hidden="true">
<rect width="280" height="128" fill="${bg}"/>
<ellipse cx="140" cy="106" rx="98" ry="8" fill="rgba(24,24,27,0.10)"/>
<path d="${roof}" fill="${accent}" opacity="0.22"/>
<path d="M 42 86 Q 48 70 72 68 L 208 68 Q 234 70 240 86 L 240 96 Q 240 100 232 100 L 48 100 Q 42 100 42 94 Z" fill="${accent}"/>
<path d="${roof}" fill="none" stroke="${accent}" stroke-width="3.5" stroke-linejoin="round"/>
<circle cx="84" cy="98" r="14" fill="#18181B"/>
<circle cx="84" cy="98" r="6" fill="#E4E4E7"/>
<circle cx="198" cy="98" r="14" fill="#18181B"/>
<circle cx="198" cy="98" r="6" fill="#E4E4E7"/>
</svg>
`;
}
function pctFromVal(val) {
return ((val - MIN_PRICE) / (MAX_PRICE - MIN_PRICE)) * 100;
}
function valFromClientX(clientX) {
const rect = trackWrap.getBoundingClientRect();
const ratio = Math.max(0, Math.min(1, (clientX - rect.left) / rect.width));
const raw = MIN_PRICE + ratio * (MAX_PRICE - MIN_PRICE);
return Math.round(raw / STEP) * STEP;
}
function updateUI() {
const pMin = pctFromVal(rangeMin);
const pMax = pctFromVal(rangeMax);
thumbMin.style.left = `${pMin}%`;
thumbMax.style.left = `${pMax}%`;
trackFill.style.left = `${pMin}%`;
trackFill.style.width = `${pMax - pMin}%`;
thumbMin.setAttribute('aria-valuenow', rangeMin);
thumbMax.setAttribute('aria-valuenow', rangeMax);
rangeReadout.innerHTML = `<span>$${rangeMin}</span> – <span>$${rangeMax}${rangeMax === MAX_PRICE ? '+' : ''}</span> / day`;
// Highlight histogram bars inside selected price range
const binWidth = (MAX_PRICE - MIN_PRICE) / BIN_COUNTS.length;
barEls.forEach((bar, idx) => {
const binMid = MIN_PRICE + (idx + 0.5) * binWidth;
bar.classList.toggle('in-range', binMid >= rangeMin && binMid <= rangeMax);
});
// Filter vehicles
const matches = VEHICLES.filter(v => {
const priceOk = v.price >= rangeMin && (rangeMax === MAX_PRICE ? true : v.price <= rangeMax);
const catOk = activeCat === 'all' || v.cat === activeCat;
return priceOk && catOk;
});
matchCount.innerHTML = `<strong>${matches.length} ${matches.length === 1 ? 'vehicle' : 'vehicles'}</strong> available in range`;
if (matches.length > 0) {
const avg = Math.round(matches.reduce((s, v) => s + v.price, 0) / matches.length);
avgReadout.textContent = `Avg $${avg}/day in view`;
} else {
avgReadout.textContent = 'Expand range to see cars';
}
carGrid.innerHTML = '';
if (matches.length === 0) {
carGrid.innerHTML = `<div class="empty-box">No vehicles between <strong>$${rangeMin}</strong> and <strong>$${rangeMax}/day</strong>. Try widening the slider handles or resetting filters.</div>`;
return;
}
matches.forEach(v => {
const card = document.createElement('article');
card.className = 'car-card';
card.innerHTML = `
${carSvg(v.tint, v.cat)}
<div class="car-body">
<div class="car-head">
<h2 class="car-name">${v.name}</h2>
<span class="car-rating"><span>★</span> ${v.rating} (${v.trips})</span>
</div>
<div class="car-specs">${v.specs}</div>
<div class="car-footer">
<span class="car-tag">${v.cat}</span>
<span class="car-price">$${v.price}<small>/day</small></span>
</div>
</div>
`;
carGrid.appendChild(card);
});
}
// Dual-handle dragging
let dragging = null; // 'min' | 'max'
function startDrag(which, e) {
dragging = which;
const el = which === 'min' ? thumbMin : thumbMax;
el.classList.add('active');
el.setPointerCapture(e.pointerId);
}
function moveDrag(e) {
if (!dragging) return;
const val = valFromClientX(e.clientX);
if (dragging === 'min') {
rangeMin = Math.max(MIN_PRICE, Math.min(rangeMax - STEP * 2, val));
} else {
rangeMax = Math.min(MAX_PRICE, Math.max(rangeMin + STEP * 2, val));
}
updateUI();
}
function endDrag() {
if (!dragging) return;
thumbMin.classList.remove('active');
thumbMax.classList.remove('active');
dragging = null;
}
thumbMin.addEventListener('pointerdown', e => startDrag('min', e));
thumbMax.addEventListener('pointerdown', e => startDrag('max', e));
window.addEventListener('pointermove', moveDrag);
window.addEventListener('pointerup', endDrag);
window.addEventListener('pointercancel', endDrag);
// Clicking on the track jumps the nearest handle
trackWrap.addEventListener('pointerdown', e => {
if (e.target === thumbMin || e.target === thumbMax) return;
const val = valFromClientX(e.clientX);
const distMin = Math.abs(val - rangeMin);
const distMax = Math.abs(val - rangeMax);
if (distMin <= distMax) {
rangeMin = Math.max(MIN_PRICE, Math.min(rangeMax - STEP * 2, val));
startDrag('min', e);
} else {
rangeMax = Math.min(MAX_PRICE, Math.max(rangeMin + STEP * 2, val));
startDrag('max', e);
}
updateUI();
});
// Keyboard support on both thumbs
thumbMin.addEventListener('keydown', e => {
if (e.key === 'ArrowRight' || e.key === 'ArrowUp') { e.preventDefault(); rangeMin = Math.min(rangeMax - STEP * 2, rangeMin + STEP); updateUI(); }
if (e.key === 'ArrowLeft' || e.key === 'ArrowDown') { e.preventDefault(); rangeMin = Math.max(MIN_PRICE, rangeMin - STEP); updateUI(); }
});
thumbMax.addEventListener('keydown', e => {
if (e.key === 'ArrowRight' || e.key === 'ArrowUp') { e.preventDefault(); rangeMax = Math.min(MAX_PRICE, rangeMax + STEP); updateUI(); }
if (e.key === 'ArrowLeft' || e.key === 'ArrowDown') { e.preventDefault(); rangeMax = Math.max(rangeMin + STEP * 2, rangeMax - STEP); updateUI(); }
});
// Category buttons & reset
document.querySelectorAll('.cat-btn').forEach(btn => {
btn.addEventListener('click', () => {
document.querySelectorAll('.cat-btn').forEach(b => b.setAttribute('aria-pressed', 'false'));
btn.setAttribute('aria-pressed', 'true');
activeCat = btn.dataset.cat;
updateUI();
});
});
document.getElementById('resetBtn').addEventListener('click', () => {
rangeMin = MIN_PRICE;
rangeMax = MAX_PRICE;
activeCat = 'all';
document.querySelectorAll('.cat-btn').forEach(b => b.setAttribute('aria-pressed', String(b.dataset.cat === 'all')));
updateUI();
});
updateUI();
})();
</script>
</body>
</html>