JSFiddle - React, Tailwind, and code Playground
HTML
<div class="wrapper">
<div class="door"></div>
<label for="check"></label>
<input type="checkbox" id="check">
</div>
CSS
.wrapper {
margin: 0 auto;
height: 150px;
width: 100px;
border: 2px solid #666;
position: relative;
}
.door {
background-color: #FFF;
display: block;
cursor: pointer;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
transition: right 0.3s linear 0s;
border: 2px solid #666;
}
.door:after {
content: '';
position: absolute;
width: 5px;
height: 5px;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
background-color: #666;
top: 50%;
right: 10px;
}
label {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
-moz-user-select: -moz-none;
-webkit-user-select: none;
user-select: none;
}
input:checked ~ .door {
right: 80%;
}
input {
display: none;
}