Animated Stat Counters
Stat numbers that count up with easing on button click.
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 text-center" style="max-width:340px"><div class="card-body">
<div class="row">
<div class="col"><div class="h3 fw-bold text-primary mb-0" id="cu1">0</div><small class="text-secondary">Users</small></div>
<div class="col"><div class="h3 fw-bold text-primary mb-0" id="cu2">0</div><small class="text-secondary">Sales</small></div>
<div class="col"><div class="h3 fw-bold text-primary mb-0" id="cu3">0</div><small class="text-secondary">Reviews</small></div>
</div>
<button class="btn btn-primary btn-sm mt-3" id="cuBtn">Animate</button>
</div></div>function run(id,to){var el=document.getElementById(id),s=null;function step(t){if(!s)s=t;var p=Math.min((t-s)/1200,1);el.textContent=Math.floor((1-Math.pow(1-p,3))*to).toLocaleString();if(p<1)requestAnimationFrame(step)}requestAnimationFrame(step)}
document.getElementById('cuBtn').onclick=function(){run('cu1',12480);run('cu2',3294);run('cu3',872)};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.