JSFiddle - React, Tailwind, and code Playground
HTML
<input type="checkbox" id="toggler"/>
<label for="toggler">Click me</label>
<div>
Hello, world!
</div>
CSS
input[type="checkbox"] {
/* display: none не будет работать в ie11 */
position: absolute;
left: -9999em;
}
label {
display: inline-block;
border: 1px solid currentColor;
padding: 5px 10px;
color: black;
cursor: pointer;
user-select: none;
float: right;
}
div {
position: absolute;
left: 0;
top: 0;
width: 400px;
height: 100%;
padding: 20px;
box-sizing: border-box;
background: black;
color: white;
z-index: 10;
transition: transform ease-out 0.25s;
transform: translateX(-100%);
}
input[type="checkbox"]:checked ~ div {
transform: translateX(0);
}