Last active
January 7, 2023 10:29
-
-
Save thetwopct/300f08de95e263fdffc954b2e23e672c to your computer and use it in GitHub Desktop.
Toggle example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#wcvat-toggle { | |
margin: 0 4rem; | |
padding: 0; | |
position: relative; | |
border: none; | |
height: 1.5rem; | |
width: 3rem; | |
border-radius: 1.5rem; | |
color: #6b7381; | |
background: #bdc1c8; | |
} | |
#wcvat-toggle:focus, | |
#wcvat-toggle.focus, | |
#wcvat-toggle:focus.on, | |
#wcvat-toggle.focus.on { | |
outline: none; | |
} | |
#wcvat-toggle:before, | |
#wcvat-toggle:after { | |
line-height: 1.5rem; | |
width: 4rem; | |
text-align: center; | |
font-weight: 600; | |
font-size: 0.75rem; | |
text-transform: uppercase; | |
letter-spacing: 2px; | |
position: absolute; | |
bottom: 0; | |
transition: opacity 0.25s; | |
} | |
#wcvat-toggle:before { | |
content: "Off"; | |
left: -4rem; | |
} | |
#wcvat-toggle:after { | |
content: "On"; | |
right: -4rem; | |
opacity: 0.5; | |
display: unset; | |
} | |
#wcvat-toggle > .handle { | |
position: absolute; | |
top: 0.1875rem; | |
left: 0.1875rem; | |
width: 1.125rem; | |
height: 1.125rem; | |
border-radius: 1.125rem; | |
background: #fff; | |
transition: left 0.25s; | |
} | |
#wcvat-toggle.on { | |
transition: background-color 0.25s; | |
} | |
#wcvat-toggle.on > .handle { | |
left: 1.6875rem; | |
transition: left 0.25s; | |
} | |
#wcvat-toggle.on:before { | |
opacity: 0.5; | |
} | |
#wcvat-toggle.on:after { | |
opacity: 1; | |
} | |
#wcvat-toggle:before, | |
#wcvat-toggle:after { | |
color: #6b7381; | |
} | |
#wcvat-toggle.on { | |
background-color: #29b5a8; | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<button id="wcvat-toggle" type="button" class="btn btn-toggle wcvat-toggle-product" data-toggle="button" aria-pressed="false" autocomplete="off"> | |
<div class="handle"></div> | |
</button> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment