JSFiddle - React, Tailwind, and code Playground
HTML
<a href="#" class="button" data-module="modules/AnimatedArrowButton" data-contact-button>
<span>Tell me more</span>
</a>
CSS
/* --- hopefully this is in your framework --- */
*{box-sizing: border-box;}
.button, .promo__button{
display: inline-block;
overflow: hidden;
position: relative;
width: 240px;
height: 70px;
background: #E21710;
color: #fff;
text-decoration: none;
text-transform: uppercase;
font-weight: bold;
font-family: sans-serif;
}
/* --- text --- */
.button span{
position: absolute;
display: inline-block;
white-space: nowrap;
margin: 0;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.promo__button span{
animation: TEXT-IN 0.5s forwards;
}
.promo__button:hover span{
animation: TEXT-OUT 0.5s forwards;
}
/* --- arrow --- */
.promo__button::before{
position: absolute;
display: inline-block;
height: 2px;
background: #fff;
content: " ";
top: 50%;
animation: LINE-OUT 1s forwards;
}
.promo__button::after{
position: absolute;
display: inline-block;
border-top: 2px solid #fff;
border-right: 2px solid #fff;
content: " ";
top: 50%;
right: 30%;
margin-right: -5px;
margin-top: 1px;
transform-origin: center;
opacity: 0;
transform: translate(-50%, -50%) rotate(45deg);
animation: ARROWHEAD-OUT 1s forwards;
}
.promo__button:hover::before{
animation: LINE-IN 1s forwards;
}
.promo__button:hover::after{
animation: ARROWHEAD-IN 1s forwards;
}
/* --- animations --- */
@-webkit-keyframes TEXT-IN {
0% { margin-left: -30px; opacity: 0; }
100% { margin-left: 0; opacity: 1; }
}
@-webkit-keyframes TEXT-OUT {
0% { margin-left: 0; opacity: 1; }
100% { margin-left: 30px; opacity: 0; }
}
@-webkit-keyframes LINE-IN {
0% { left: 0; right: 100%; }
50% { left: 0; right: 30%; }
100% { left: 30%; right: 30%; }
}
@-webkit-keyframes LINE-OUT {
0% { width: 40%; transform: translateX(-50%); left: 50%; }
100% { width: 40%; transform: translateX(100%); left: 100%; }
}
@-webkit-keyframes ARROWHEAD-IN {
60% { width: 0; height: 0; opacity: 0; }
65% { width: 0; height: 0; opacity:...
JavaScript
$('.button').hover(function(){
$(this).addClass('promo__button');
});