-
-
Save pakMann/1c642cef52480e3fb297e1b4c3a68293 to your computer and use it in GitHub Desktop.
Sass mixin for checkbox and radio replacement
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
| //Checkbox icon replacement | |
| //$cb-icon = calss name of icon | |
| //$cb-icon-checked = class name for checked icon | |
| @mixin checkbox ($cb-icon, $cb-icon-checked) { | |
| %checked { | |
| @extend %icon; | |
| @extend .#{$cb-icon-checked}:before; | |
| text-align: center; | |
| } | |
| label{ | |
| display: inline-block; | |
| cursor: pointer; | |
| position: relative; | |
| &:before{ | |
| @extend %icon; | |
| @extend .#{$cb-icon}:before; | |
| display: inline-block; | |
| position: absolute; | |
| left: 0; | |
| bottom: 1px; | |
| } | |
| } | |
| input[type="checkbox"], | |
| input[type="radio"] { | |
| display: none; | |
| &:checked + label:before { | |
| @extend %checked; | |
| } | |
| } | |
| :checked + label:before { | |
| @extend %checked; | |
| } | |
| } | |
| @mixin radio($cb-icon, $cb-icon-checked) { | |
| @include checkbox($cb-icon, $cb-icon-checked); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment