Last active
February 1, 2023 10:44
-
-
Save otakupahp/367ad86769217cb302755f28bbc918a2 to your computer and use it in GitHub Desktop.
Nice Checkbox
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
| <label for="check">Check</label> | |
| <input | |
| type="checkbox" | |
| class="ui-toggle" | |
| id="check" | |
| name="check" | |
| value="1" | |
| > |
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
| /* Colors */ | |
| input[type=checkbox].ui-toggle { | |
| -webkit-appearance: none; | |
| -moz-appearance: none; | |
| appearance: none; | |
| -webkit-tap-highlight-color: transparent; | |
| width: auto; | |
| height: auto; | |
| vertical-align: middle; | |
| position: relative; | |
| border: 0; | |
| outline: 0; | |
| cursor: pointer; | |
| margin: 0 4px; | |
| background: none; | |
| box-shadow: none; | |
| } | |
| input[type=checkbox].ui-toggle:focus { | |
| box-shadow: none; | |
| } | |
| input[type=checkbox].ui-toggle:before { | |
| content: ""; | |
| width: 21px; | |
| height: 21px; | |
| display: block; | |
| position: absolute; | |
| top: 2px; | |
| left: 2px; | |
| margin: 0; | |
| border-radius: 50%; | |
| background-color: #ffffff; | |
| } | |
| input[type=checkbox].ui-toggle:after { | |
| content: "NO"; | |
| text-indent: 28px; | |
| font-size: 12px; | |
| font-weight: bold; | |
| line-height: 26px; | |
| color: #0A2645; | |
| width: 60px; | |
| height: 25px; | |
| display: inline-block; | |
| background-color: #d8d8d8; | |
| border-radius: 72px; | |
| box-shadow: 0 0 12px rgba(0, 0, 0, 0.15) inset; | |
| } | |
| input[type=checkbox].ui-toggle:checked:before { | |
| left: 37px; | |
| } | |
| input[type=checkbox].ui-toggle:checked:after { | |
| content: "YES"; | |
| text-indent: 8px; | |
| color: #ffffff; | |
| background-color: #0A2645; | |
| } | |
| input[type=checkbox].ui-toggle, input[type=checkbox].ui-toggle:before, input[type=checkbox].ui-toggle:after, input[type=checkbox].ui-toggle:checked:before, input[type=checkbox].ui-toggle:checked:after { | |
| transition: ease 0.15s; | |
| } |
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
| /* Colors */ | |
| $white: #ffffff; | |
| $grey: #d8d8d8; | |
| $dark: #0A2645; | |
| input[type="checkbox"].ui-toggle { | |
| -webkit-appearance: none; | |
| -moz-appearance: none; | |
| appearance: none; | |
| -webkit-tap-highlight-color: transparent; | |
| width: auto; | |
| height: auto; | |
| vertical-align: middle; | |
| position: relative; | |
| border: 0; | |
| outline: 0; | |
| cursor: pointer; | |
| margin: 0 4px; | |
| background: none; | |
| box-shadow: none; | |
| &:focus { | |
| box-shadow: none; | |
| } | |
| &:before { | |
| content: ''; | |
| width: 21px; | |
| height: 21px; | |
| display: block; | |
| position: absolute; | |
| top: 2px; | |
| left: 2px; | |
| margin: 0; | |
| border-radius: 50%; | |
| background-color: $white; | |
| } | |
| &:after { | |
| content: 'NO'; | |
| text-indent: 28px; | |
| font-size: 12px; | |
| font-weight: bold; | |
| line-height: 26px; | |
| color: $dark; | |
| width: 60px; | |
| height: 25px; | |
| display: inline-block; | |
| background-color: $grey; | |
| border-radius: 72px; | |
| box-shadow: 0 0 12px rgb(0 0 0 / 15%) inset; | |
| } | |
| &:checked:before { | |
| left: 37px; | |
| } | |
| &:checked:after { | |
| content: 'YES'; | |
| text-indent: 8px; | |
| color: $white; | |
| background-color: $dark; | |
| } | |
| &, | |
| &:before, | |
| &:after, | |
| &:checked:before, | |
| &:checked:after { | |
| transition: ease .15s; | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The CodePen could be seen at:
https://codepen.io/otakupahp/pen/QWMwENv