Range with Live Preview
A range slider that live-adjusts a preview swatch.
Requires Bootstrap 5. Add the CDN tags below to your page (styles in
<head>, scripts before </body>). The downloaded file already includes them.<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"><script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script><div class="card border-0 shadow-sm" style="max-width:340px"><div class="card-body">
<label class="form-label small fw-semibold d-flex justify-content-between">Brightness <span id="rfVal">60%</span></label>
<input type="range" class="form-range" id="rfInput" value="60">
<div class="mt-2 rounded" id="rfPreview" style="height:40px;background:#000;opacity:.6;transition:opacity .1s"></div>
</div></div>var r=document.getElementById('rfInput'),v=document.getElementById('rfVal'),p=document.getElementById('rfPreview');
r.addEventListener('input',function(){v.textContent=r.value+'%';p.style.background='hsl(45,90%,'+(r.value/2)+'%)';p.style.opacity=1});Free to use.This component uses Bootstrap 5 (linked above). Copy any file, or download a ready-to-open .html page with the CDN links already included.