css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <h1>Visual affordance in checkbox controls</h1>
<h2>Unchecked &amp; Enabled</h2>
<div class="checkbox">
  <input type="checkbox" id="check_01">
  <label for="check_01"></label>
</div>

<h2>Unchecked &amp; Disabled</h2>
<p>'Lock' icon version. Nice but may get confused with 'secure'.</p>
<div class="checkbox disabled">
  <input type="checkbox" id="check_02" disabled>
  <label for="check_02"></label>
</div>

<h2>Checked &amp; Disabled</h2> <p>Alternative 'ban/not-allowed' styled version - more in keeping with not-allowed  cursor</p>
<div class="checkbox ban disabled checked">
  <input type="checkbox" id="check_03" checked disabled>
  <label for="check_03"></label>
</div>

<h2>SPECIAL</h2>
<sp>With label-like 'off' and 'on' indicators, populated in this case using ::before/::after content</p>
<div class="checkbox checked">
  <input type="checkbox" id="check_04">
  <label for="check_04"><span class="indicators" data-label-off="off" data-label-on="on"></span></label>
</div>
<p>Go forth, code Ninja, and play&hellip;</p>

            
          
!
            
              // THIS ISN'T ORGANISED OR OPTIMISED VERY WELL. SORRY ABOUT THAT, FOLKS!

@import "compass/css3";
*, *:after, *:before{
  @include box-sizing(border-box);
}
$prim : hsla(150, 100%, 50%, 1);
$dark : hsla(150, 100%, 25%, 1);
html {
  font-size: 16px;
}
body{
  font: 400 normal normal 100%/1.5 Nunito, sans-serif;
  text-align: center;
  background: $prim;
  padding: 50px;
}

h1, h2 {
  font-weight: 700;
}
h1 {
  margin: 0 0 3rem;
}
h2 {
  margin: 0;
}
p {
  margin: 0 0 1.5rem;
}
/*=====================*/
.checkbox {
  position: relative;
  display: block;
  margin: 1rem auto 3rem;
  label {
    width: 90px;
    height: 42px;
    background: lighten($prim, 35%);
    position: relative;
    display: inline-block;
    @include border-radius(46px);
    @include transition(.25s);
    box-shadow: inset 0 3px 3px hsla(150, 100%, 0%, 0.25);
    &:after, 
    &:before{
      content: '';
      text-shadow: 0px 0px 2px hsla(0, 0%, 0%, 0.25);
      position: absolute;
      width: 50px;
      height: 50px;
      @include border-radius(100%);
      left: 0;
      top: -5px;
      background: #fff;
      @include box-shadow(0 0 5px rgba(0,0,0,.2));
      @include transition(.25s);
    }
    &:before{
      content: '\f08d';
      content: '\f00d';
      font-family: FontAwesome;
      font-weight: normal;
      font-size: 24px;
      line-height: 50px;
      color: $prim;
      color: hsla(0, 100%, 50%, 1);
      z-index: 1;
      overflow: hidden;
       //@include animation(.25s pin-off forwards)
    }
  }
  input{
    position: absolute;
    right: 0;
    top: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    opacity: 0;
   cursor: pointer;
    &:not(:checked) ~ label .indicators::before {
      color: red;
    }
    &:checked ~ label .indicators::after {
      color: blue;
    }
    &:not(:disabled):hover + label:after {
      @include box-shadow(0 2px 15px 0 rgba(0, 0, 0, .2), 0 3px 8px 0 rgba(0, 0, 0, .15))
    }
    &:checked + label{
      background: $dark;
      &:after, 
      &:before{
        content: "\f00c"; // tick (check)
        background: $prim;
        color: #fff;
        left: 40px;
      }
      &:before{
        @include animation(.25s pin-on  forwards);
      }
    }   
  }  
}
/*
@include keyframes(pin-on){
  80%{ line-height: 150px;}
  85%{ line-height: 1px; @include rotate(45deg); opacity:0}
  100%{ line-height: 50px; opacity:1; @include rotate(45deg)}
}
@include keyframes(pin-off){
   0%{@include rotate(45deg)}
  80%{ line-height: 150px; }
  85%{ line-height: 1px; opacity:0}
  100%{ line-height: 50px; opacity:1; }
}
*/
.checkbox {
  position: relative;
  width: 100px;
}
.checkbox.disabled::after {
	content: "\f023";
	position: absolute;
	top: 10px;
	left: 66px;
	font-family: FontAwesome;
  color: hsla(0, 0%, 0%, 0.5);
  text-shadow: 0px 1px 1px hsla(0, 0%, 0%, 0.25);
}
// OR this version!
.checkbox.ban.disabled::after {
  content: '\f05e';
}
.checkbox.disabled.checked::after {
	left: 24px;
  color: hsla(0, 0%, 100%, 0.75);
}
.disabled {
  input {
    cursor: not-allowed;
  }
}
small {
  display: block;
  font-size: 12px;
  font-weight: normal;
}
.indicators {
  text-transform: uppercase;
  font-weight: bold;
  &::before,
  &::after {
    position: absolute;
    line-height: 40px;
    cursor: pointer;
  }
  &::before {
    left: -50px;
    text-align: right;
    content: attr(data-label-off);
  }
  &::after {
    right: -50px;
    text-align: left;
    content: attr(data-label-on);
  }
}
input:checked {
  & ~ .indicators {
    
  }
}
            
          
!
            
              /* NEED TO DO/CHECK:
 - Code tidy
 - Accessibility
 - Varieties of display
 - Text direction (RTL) agnostic
*/
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console