JSFiddle - React, Tailwind, and code Playground

by anoopsuda

HTML

<button class="btn-1 btn-border-animation"><span>Hover Me</span></button>

CSS

body {background:gray;}

.btn-border-animation{
  display: inline-flex;
  position: relative;
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  margin: 20px 30px;
  background: rgba(0,0,0,1);
}
.btn-border-animation::before, button::after{
  content:"";
  width: 0;
  height: 2px;
  position: absolute;
  transition: all 0.2s linear;
  background: #fff;
}
.btn-border-animation:hover::before, .btn-border-animation:hover::after{
  width: 100%;
}
.btn-border-animation:hover span::before, .btn-border-animation:hover span::after{
  height: 100%;
}
/*----- button 1 -----*/
.btn-1::before, .btn-1::after{
  transition-delay: 0.2s;
}
.btn-1 span::before, .btn-1 span::after{
  transition-delay: 0s;
}
.btn-1::before{
  right: 0;
  top: 0;
}
*, *:after, *:before {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}
.btn-1::after{
  left: 0;
  bottom: 0;
}
.btn-1 span::before{
  left: 0;
  top: 0;
}
.btn-1 span::after{
  right: 0;
  bottom: 0;
}
.btn-1:hover::before, .btn-1:hover::after{
  transition-delay: 0s;
}
.btn-1:hover span::before, .btn-1:hover span::after{
  transition-delay: 0.2s;
}
.btn-border-animation span{
  display: block;
  padding: 25px 80px;
}
.btn-border-animation span::before, .btn-border-animation span::after{
  content:"";
  width:2px;
  height:0;
  position: absolute;
  transition: all 0.2s linear;
  background: #fff;
}