JSFiddle - React, Tailwind, and code Playground

HTML

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button class="button">CLICK</button>
    <div style="min-height:1500px"></div>
    <textarea id="textarea">asd</textarea>
    <div style="min-height:2000px"></div>
    <button class="button">CLICK</button>
</body>
</html>

JavaScript

$(".button").on('click', function() {
            $('html, body').animate({
                scrollTop: $("#textarea").offset().top - ($(window).height() - $("#textarea").outerHeight(true)) / 2
            }, 1000);
        });