JSFiddle - React, Tailwind, and code Playground
HTML
<a href="#t1">Target 1</a>
<a href="#t2">Target 2</a>
<a href="#t3">Target 3</a>
<div id="t1"></div>
<div id="t2"></div>
<div id="t3"></div>
CSS
html, body {height: 100%;margin: 0;text-align: center;background: #2a2a2a}
a {color: #fff}
div {height: 100%;}
div:nth-of-type(1) {margin-top: 200px;background: #09f}
div:nth-of-type(2) {background: #90f}
div:nth-of-type(3) {background: #f09}
JavaScript
var a = document.querySelectorAll("a[href^='#']");
var duration = 800;
var i = 0,
l = a.length;
for (; i<l; i++) a[i].addEventListener("click", function (e){
e.preventDefault();
var scroll = function (){
var progress = Math.min(1, (new Date - start) / duration);
window.scrollTo(0, (to - from) * Math.pow(progress, 2) + from);
(progress < 1) && window.requestAnimationFrame(scroll);
}
var start = new Date,
from = window.pageYOffset,
to = document.getElementById(this.hash.substring(1)).offsetTop;
scroll();
}, false);