JSFiddle - React, Tailwind, and code Playground

by Manjula Dhamodharan

HTML

<nav>
    <ul>
        <li><a href="#" id="btn1">Home</a></li>
        <li><a href="#" id="btn2" >About</a></li>
    </ul>
</nav>

CSS

nav a#btn1 {
    background-position:0px 0px;
    width:82px;
    
}

nav a#btn1:hover {
    background-position:0px -82px;
}

nav a#btn1.active {
    background-position:0px -164px;
}

nav a#btn2 {
    background-position:-108px 0px;
    width:82px;
}

nav a#btn2:hover {
    background-position:-108px -82px;
}

nav a#btn2.active {
    background-position:-108px -164px;
    outline: none;
}
.nav a .active{
    font-weight:700;
}
.active{font-weight:700; }

JavaScript

$("nav li").click(function() {
    $("nav li a.active").removeClass("active"); //Remove any "active" class  
    $("a", this).addClass("active"); //Add "active" class to selected tab  

    $(activeTab).show(); //Fade in the active content  
    return false;
}