JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<div class="button">
<div class="button__text">Button text</div>
</div>
</body>
</html>
CSS
body {
background-color: #222;
}
.button {
background-color: white;
padding: 20px;
border-radius: 40px;
margin: 40px;
width: 250px;
position: relative;
overflow: hidden;
transition: all 0.2s;
}
.button::before{
content: '';
position: absolute;
left: -10px;
top: -10px;
width: calc(100% + 20px);
height: calc(100% + 20px);
background-color: transparent;
transition: 0.5s;
}
.button__text {
position: relative;
z-index: 1;
color: black;
}
.button:hover::before {
background-color: black;
}
.button:hover .button__text {
color: white;
}