cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

            
              
.wrapper
  .ripple
  .content
    p.header Material design switch
    ul
      li
        p Some Option 1
        input#test(type='checkbox', hidden)
        label.switch(for='test')
      li
        p Some Option 2
        input#test1(type='checkbox', hidden)
        label.switch(for='test1')
      li
        p Some Option 3
        input#test2(type='checkbox', hidden)
        label.switch(for='test2')
  .footer
    button.button.theme(type='button') Switch Theme
            
          
!
            
              @import url(https://fonts.googleapis.com/css?family=Roboto);


$grid-step = 0.25rem

$size = $grid-step * 10
$height = $grid-step * 4
$padding = $grid-step
$border-radius = $grid-step / 2
$label = $height + ($padding * 2)

$animation-timing = cubic-bezier(0.4,0,.2,1)
$animation = .28s $animation-timing
$animation-slow = .56s $animation-timing

$color-swatch = #8BC34A
$color-dark-swatch = #80CBC4

$color-thumb-off = #fafafa
$color-dark-thumb-off = #bdbdbd

$color-track-off = rgba(black, 26%)
$color-dark-track-off = rgba(white, 30%)

$color-track-on = rgba($color-swatch, 50%)
$color-dark-track-on = rgba($color-dark-swatch, 50%)


body
  background #eee
  font normal normal normal ($grid-step * 4)/1 'Roboto'
  color #808080


.wrapper
  display table
  position absolute
  top 0
  left 0
  right 0
  bottom 0
  width ($size * 7)
  padding 0
  background #fff
  border-radius $border-radius
  text-align right
  margin auto
  box-shadow 0 ($grid-step * 4) ($grid-step * 10) rgba(black, .3), 0 ($grid-step * 3) ($grid-step * 3) rgba(black, .22)
  overflow hidden
  z-index 100

  & .content
    padding ($grid-step * 6) ($grid-step * 6) ($grid-step * 4)

  & .footer
    padding  0 ($grid-step * 4) ($grid-step * 2)

  & .ripple
    display block
    position absolute
    width 4px
    height 4px
    top 100%
    left 100%
    border-radius 100%
    transition box-shadow $animation-slow
    z-index -1
    will-change transform

  & .header
    display block
    font-size ($size / 2)
    text-align left
    color rgba(black, 84%)
    margin 0
    padding 0
    transition color $animation-slow

  & ul
    display block
    padding 0
    width 100%

    & li
      display block
      padding ($grid-step * 4) 0 0

      & p 
        display inline-block
        line-height ( $label )
        margin 0 ($size / 2) 0 
        vertical-align middle
        transition color $animation-slow
  
  &.dark,
  &.dark .header
    color rgba(white, 84%)

    & .ripple
      box-shadow  inset 0 0 0 ($grid-step * 2) rgba(black, 77%),
                        0 0 0 ($grid-step * 100) rgba(black, 77%)
    & .button 
      color rgba(white, .84)

    & .switch
      background $color-dark-track-off

      &::before
        background $color-dark-thumb-off

    & input:checked + .switch
        background $color-dark-track-on

        &::before
          background $color-dark-swatch
          
        &:active::before
          box-shadow 0 $grid-step ( $height / 2 ) rgba(black, .28),
               0 0 0 ($size / 2) rgba($color-dark-swatch, 0.2)    


.button
  display inline-block
  position relative
  padding 0 ($grid-step * 3)
  height ($grid-step * 9)
  border none
  margin ($grid-step * 2) 0
  cursor pointer
  border-radius 2px
  font-size ($grid-step * 4)
  text-transform uppercase
  text-decoration none
  color rgba(black, .84)
  background none
  transition box-shadow $animation,
             color $animation
  outline none

  &:hover
    box-shadow 0 3px 6px rgba(black, .2),
               0 3px 6px rgba(black, .28)
  &:active
    box-shadow 0 10px 20px rgba(black, .19),
               0 6px 6px rgba(black, .23)


.switch
  display inline-block
  position relative
  width ( $size )
  height ( $height )
  border-radius ( $height / 2 )
  background $color-track-off
  transition background $animation
  vertical-align middle
  cursor pointer

  &::before
    content ''
    position absolute
    top ( - $padding )
    left ( - $padding )
    width ($label)
    height ($label)
    background $color-thumb-off
    box-shadow 0 $grid-step ( $height / 2 ) rgba(0,0,0,.28)
    border-radius 50%
    transition left $animation, 
               background $animation,
               box-shadow $animation
  
  &:active::before
    box-shadow 0 $grid-step  ( $height / 2 ) rgba(black, .28),
               0 0 0 ($size / 2) rgba(#808080, .1)
      
      
input:checked + .switch
  background $color-track-on
  
  &::before
    left ( $size - $label + $padding )
    background $color-swatch 
  
  &:active::before
    box-shadow 0 $grid-step ( $height / 2 ) rgba(black, .28),
               0 0 0 ($size / 2) rgba($color-swatch, 0.2)  
      
      
      
            
          
!
            
              const wrapper = document.querySelector('.wrapper');
const button = document.querySelector('.button');
const ripple = document.querySelector('.ripple');
  
button.addEventListener('click', (e) => {
  let top = button.offsetTop + e.offsetY;
  let left = button.offsetLeft + e.offsetX;
    
  Object.assign(ripple.style, {
    top: `${top}px`,
    left: `${left}px` 
  });
    
  wrapper.classList.toggle('dark');
});

            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console