JSFiddle - React, Tailwind, and code Playground
HTML
<div class="container">
<button class='button' id="clicked" onclick="onToggle()"></button>
<span class="text-1">Play</span>
<span class="text-2">Pause</span>
</div>
CSS
.container {
padding: 10px;
border: 1px solid;
display: inline-flex;
align-items: center;
justify-content: center;
transition: all 0.2s linear;
}
.text-1, .text-2 {
display: none;
}
.button {
border: 0;
background: transparent;
box-sizing: border-box;
width: 0;
height: 20px;
border-color: transparent transparent transparent #202020;
transition: 100ms all ease;
cursor: pointer;
border-style: solid;
border-width: 10px 0 10px 20px;
padding: 0
}
.button.paused {
border-style: double;
border-width: 0px 0 0px 20px;
}
.pauseicon{
border-left: 10px solid #000;
border-right: 10px solid #000;
width: 10px;
height: 25px;
}
.button:hover {
border-color: transparent transparent transparent #404040;
}
.button:hover + .text-1 {
display: inline;
}
.pauseicon:hover ~ .text-2 {
display: inline;
}
JavaScript
function onToggle() {
document.getElementById("clicked").classList.toggle("button");
document.getElementById("clicked").classList.toggle("pauseicon");
}