Pen Settings

HTML

CSS

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

JavaScript

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

Packages

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.

Behavior

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.

HTML

              
                <div class="toggle">
  <input type="checkbox" id="btn">
  <label for="btn">
    <span class="thumb"></span>
  </label>
  <div class="light"></div>
</div>
              
            
!

CSS

              
                
:root {
  --sz: 10vmin;
  --on: #03A9F4;
  --of: #fff0;
  --gr: #666666;
  --tr: all 0.5s ease 0s;
  --lg: var(--of);
}	

* {
  box-sizing: border-box;
  transition: var(--tr);
}

body {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(45deg, #202837, #1f2425);
  background: linear-gradient(135deg, #1c232f, #1b212f, #090c10);
}

body:before, body:after {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  background: 
    repeating-conic-gradient(#0002 0.000095%, #fff0 .0005%, #fff0 .005%, #fff0 .0005%), 
    repeating-conic-gradient(#0002 0.00001%, #fff0 .00009%, #fff0 .00075%, #fff0 .000025%);
  opacity: 0.75;
  filter: blur(0.75px);
}

.toggle  {
  position: relative;
  width: calc(var(--sz) * 4);
  height: calc(var(--sz) * 2);
  display: flex;
  align-items: center;
  justify-content: center;
}

input {
  display: none;
}

label[for=btn] {
  position: absolute;
  width: calc(var(--sz) * 4);
  height: calc(var(--sz) * 2);
  background: linear-gradient(0deg, #121720, #0d1217);
  border-radius: var(--sz);
  box-shadow: 0 0 calc(var(--sz) / 50) calc(var(--sz) / 50) #0006, 0 -4px calc(var(--sz) / 10) calc(var(--sz) / 500) #0b0b10, 0 0px calc(var(--sz) / 10) calc(var(--sz) / 50) #b9e1ff88, 0 -4px calc(var(--sz) / 5) calc(var(--sz) / 50) #15182fcc;
}	

.thumb {
  position: absolute;
  width: calc(calc(var(--sz) * 2) - calc(var(--sz) / 8));
  height: calc(calc(var(--sz) * 2) - calc(var(--sz) / 8));
  top: calc(calc( var(--sz) / 10) + calc(var(--sz) / -20));
  left: calc(calc( var(--sz) / 10) + calc(var(--sz) / -30));
  background: 
    radial-gradient(circle at 48% 50%, #fff0 calc(var(--sz) / 1.05), var(--lg) calc(var(--sz) / 0.99) ), 
    radial-gradient(circle at 40% 50%, #fff0 calc(var(--sz) / 0.95), var(--lg) calc(var(--sz) / 0.75)), 
    linear-gradient(180deg, #283349, #17212f);
  border-radius: var(--sz);
  box-shadow: 
    calc(var(--sz) / -50) calc(var(--sz) / 50) calc(var(--sz) / 30) 0 #fff2 inset, 
    0 0 calc(var(--sz) / 10) calc(var(--sz) / 50) #000c, 
    0 calc(var(--sz) / 3) calc(var(--sz) / 3) 0 #000d;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  overflow: hidden;
}

#btn:checked + label .thumb {
  --lg: var(--on);
  transition: var(--tr);
  left: calc(calc(100% - calc(calc(var(--sz) * 2) - calc(var(--sz) / 3))) - calc(calc( var(--sz) / 10) + calc(var(--sz) / 5.75)));

}

.thumb:before {
  content: "";
  position: absolute;
  width: calc(var(--sz) / 0.5);
  height: calc(var(--sz) / 0.5);
  background: radial-gradient(circle at 45% 50%, #fff0 calc(var(--sz) / 1), var(--lg) calc(var(--sz) / 0.95));
  filter: blur(1px);
}

.light {
  position: absolute;
  width: calc(var(--sz) * 1);
  height: calc(var(--sz) / 1.75);
  right: calc(var(--sz) * -2.75);
  display: flex;
  justify-content: center;
  z-index: 1;
  background: #121212;
  position: relative;
  width: calc(var(--sz) / 1.75);
  height: calc(var(--sz) / 1.75);
  border-radius: var(--sz);
  box-shadow: 
    0 0px calc(var(--sz) / 50) calc(var(--sz) / 50) #0008, 
    0 -4px calc(var(--sz) / 10) calc(var(--sz) / 500) #000, 
    0 2px calc(var(--sz) / 10) calc(var(--sz) / 500) #fff8, 
    0 0px calc(var(--sz) / 20) calc(var(--sz) / 25) #000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--tr);
}

.light:before {
  content: "";
  transition: var(--tr);
  width: calc(100% - calc(var(--sz) / 15));
  height: calc(100% - calc(var(--sz) / 15));
  position: absolute;
  background: radial-gradient(circle at 50% 32%, #fff5 0 calc(var(--sz) / 20), #000 calc(var(--sz) / 3) calc(var(--sz) / 3));
  border-radius: var(--sz);
  box-shadow: 
    0 0 calc(var(--sz) / 3) 0 #003ef520, 
    0 0 calc(var(--sz) / 3) calc(var(--sz) / 20) #003ef520 inset;
}

#btn:checked + label + .light:before {
  --lg: var(--on);
  transition: var(--tr);
  box-shadow: 
    0 0 calc(var(--sz) / 2.5) 0 var(--lg), 
    0 0 calc(var(--sz) / 3) calc(var(--sz) / 20) var(--lg) inset, 
    0 calc(var(--sz) / -20) calc(var(--sz) / 10) calc(var(--sz) / 10) #000c inset;
  background: radial-gradient(circle at 50% 32%, #fff 0 calc(var(--sz) / 20), var(--lg) calc(var(--sz) / 3) calc(var(--sz) / 3));
}
              
            
!

JS

              
                
              
            
!
999px

Console