JSFiddle - React, Tailwind, and code Playground
HTML
<div>
<a href="#"><span>Underline will fade-in</span></a>
</div>
CSS
body {
font-family: Calibri;
font-size: 20px;
padding: 10px;
}
a {
position: relative;
display: inline-block;
transition: .3s;
text-decoration: none;
}
a::after,
a::before {
position: absolute;
left: 0;
content: '';
width: 100%;
height: 1px;
background-color: green;
opacity: 0;
transition: .3s;
}
a:hover::before {
top: 0;
opacity: 1;
}
a:hover::after {
bottom: 0;
opacity: 1;
}
a:hover {
color: green;
}