JSFiddle - React, Tailwind, and code Playground
Simple Switch
by tonytlwu
HTML
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<label class="checkbox-toggle">
<input type="checkbox" />
<div class="switch-label">
Portrait
<span class="switch"></span>
Landscape
</div>
</label>
SCSS
$toggle-height: 22px;
$switch-size: 16px;
.checkbox-toggle {
display: inline-block;
overflow: hidden;
background: #666666;
color: #fff;
padding: 4px;
height: $toggle-height;
line-height: $toggle-height;
border-radius: $toggle-height/2;
user-select: none;
> input[type="checkbox"] {
visibility: hidden;
opacity: 0;
position: absolute;
top: -9999px;
&:checked + .switch-label {
}
}
> .switch-label {
display: flex;
font-weight: normal;
.switch {
display: inline-block;
width: $switch-size;
height: $switch-size;
background: #fff;
border-radius: 50%;
margin: 0 2px;
}
}
}