Skip to content

Instantly share code, notes, and snippets.

@b-ry
Last active May 15, 2016 21:12
Show Gist options
  • Select an option

  • Save b-ry/9010691 to your computer and use it in GitHub Desktop.

Select an option

Save b-ry/9010691 to your computer and use it in GitHub Desktop.
Sass mixin for checkbox and radio replacement
//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