Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

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


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <div class="switch-wrap">
    <input id="toggleLights" type="checkbox" />
    <label for="toggleLights" class="switch">
        <div class="slide-wrap">
            <div class="slide">
                <div class="slider"></div>



                @import compass

$switch-height: 38px
$switch-width: 108px

$greencolor: #00c913
$redcolor: #e00150


@function black($opacity)
  @return rgba(0,0,0,$opacity)

@function white($opacity)
  @return rgba(255,255,255,$opacity)

  height: 100%

  background: #333
  position: relative
  margin: 0
  height: 100%
  +single-transition(background, .2s)

    background: #ccc

  position: absolute
  top: 50%
  left: 50%
  margin-top: -(($switch-height + 14px)/2)
  margin-left: -(($switch-width + 14px)/2)
  padding: 7px 0
  +box-shadow(inset -2px 2px 14px black(0.5), 0px -1px 0px 0px white(0.1))
  border: 1px solid black(0.3)
  width: $switch-width + 14px
  +single-transition(box-shadow, .2s)
  .lights-is-active &
    +box-shadow(inset -2px 2px 14px black(0.2), 0px -1px 0px 0px white(0.5))

    visibility: hidden
    position: absolute
    top: 9999px
    left: 9999px

  input:checked + .switch
      margin-left: 0

  border: 1px solid #000
  display: block
  text-decoration: none
  position: relative
  overflow: hidden
  height: $switch-height
  width: $switch-width
  cursor: pointer
  margin: 0px auto

    height: $switch-height - 2
    background: #000
    width: $switch-width * 1.5
    position: absolute
    top: -1px
    margin-left: -($switch-width / 2)
    +single-transition(margin-left, .1s)

    position: relative
    width: 100%
    height: $switch-height - 2

    &:before, &:after, .slider
      display: inline-block
      text-transform: uppercase
      font-family: sans-serif
      width: ($switch-width / 2)
      height: $switch-height - 2
      text-align: center
      color: #fff
      position: absolute
      font-family: 'Helvetica', sans-serif
      top: 1px

    &:before, &:after
      text-shadow: 0px 1px 0px rgba(255,255,255,0.2)
      border: 1px solid rgba(0,0,0,0.5)
      +box-shadow(inset 0px 0px 10px rgba(0,0,0,0.6))
      line-height: $switch-height - 2
      font-size: 11px

      content: 'ON'
      background: darken($greencolor, 10%)
      left: 0
      z-index: 1
      color: darken($greencolor, 30%)

      content: 'OFF'
      background: darken($redcolor, 10%)
      right: 0
      top: auto
      z-index: 1
      color: darken($redcolor, 30%)

    background: #666
    border: 1px solid white(0.1)
    border-bottom: 1px solid white(0.3)
    left: ($switch-width / 2)
    width: $switch-width / 3
    z-index: 4
    +background(linear-gradient(top, #aaa 0%, #ccc 100%))
    +box-shadow(0px 0px 20px black(0.8), 0px 1px 0px 0px black(0.5), 0px -1px 0px 0px black(0.5))



                // I could have done this all in CSS with
// input:checked but... why?

$('#toggleLights').on('click', function(e) {