JSFiddle - React, Tailwind, and code Playground

HTML

<div class='spacer'>This just here to simulate scrolling</div>
<div class='menu'>Your Menu Here</div>
<div class='spacer'>This just here to simulate scrolling</div>

CSS

div.menu {
    position: static;
    background-color: green;
    top: 0px;
    width: 200px;
}
div.spacer {
    padding: 300px 0;
}

JavaScript

var t = $('.menu').offset().top;
$(window).scroll(function() {
    if ($(this).scrollTop() > t)
        $('.menu').css('position','fixed');
    else
        $('.menu').css('position','static');
});