JSFiddle - React, Tailwind, and code Playground
HTML
<a href="#test" class="smoothScroll">Go to test</a>
<div id="test"></div>
CSS
#test {
background-color: yellowgreen;
width: 300px;
height: 300px;
margin-top: 2000px;
}
JavaScript
$('.smoothScroll').click(function(e){
var offset = $(this.hash).offset().top;
$('html, body').stop().animate({
scrollTop: offset - (window.innerHeight/2) + ($(this.hash).innerHeight()/2)
}, 400 );
return false;
});