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

              
                <section class="light-bulbs">
 <div class="light-bulb theme-color-one">
  <input type="color" class="color-setting hidden" value="#025ba0" data-theme-color="one" />
 </div>
 <div class="light-bulb theme-color-two">
  <input type="color" class="color-setting hidden" value="#9bc72b" data-theme-color="two" />
 </div>
 <div class="light-bulb theme-color-three">
  <input type="color" class="color-setting hidden" value="#f0c517" data-theme-color="three" />
 </div>
 <div class="light-bulb theme-color-four">
  <input type="color" class="color-setting hidden" value="#bf1724" data-theme-color="four" />
 </div>
 <div class="light-bulb theme-color-five">
  <input type="color" class="color-setting hidden" value="#5cc9f4" data-theme-color="five" />
 </div>
 <div class="light-bulb theme-color-one">
  <input type="color" class="color-setting hidden" value="#025ba0" data-theme-color="one" />
 </div>
</section>

<section class="light-bulb-settings">
 <h3>Settings</h3>
 <div class="group">
  <label>State:</label>
  <div class="checkbox-container">
   <input type="checkbox" class="light-switch" data-elem="switch" />
  </div>
  <span class="light-switch-state">off</span>
 </div>

 <div class="group">
  <label>Interval:</label>
  <input class="interval-control" type="number" value="1.1" step="0.1" min="0.1" max="2" data-elem="interval" />
 </div>

 <button class="color-wheel">Toggle color wheel</button>
</section>
              
            
!

CSS

              
                :root {
 --theme-color-one: #025ba0;
 --theme-color-two: #9bc72b;
 --theme-color-three: #f0c517;
 --theme-color-four: #bf1724;
 --theme-color-five: #5cc9f4;
 --white: #fff;
 --black: #000;
 --grey: #999;
 background: var(--black);
 color: var(--white);
}

body {
 font-family: "Alatsi", sans-serif;
}

@keyframes light-up-theme-color-one {
 0% {
  box-shadow: 0 1px 10px 5px var(--theme-color-one);
 }
 25% {
  box-shadow: 0 1px 15px 5px var(--theme-color-one);
 }
 50% {
  box-shadow: 0 1px 20px 5px var(--theme-color-one);
 }
 75% {
  box-shadow: 0 1px 25px 5px var(--theme-color-one);
 }
 100% {
  box-shadow: none;
 }
}

@keyframes light-up-theme-color-two {
 0% {
  box-shadow: 0 1px 10px 5px var(--theme-color-two);
 }
 25% {
  box-shadow: 0 1px 15px 5px var(--theme-color-two);
 }
 50% {
  box-shadow: 0 1px 20px 5px var(--theme-color-two);
 }
 75% {
  box-shadow: 0 1px 25px 5px var(--theme-color-two);
 }
 100% {
  box-shadow: none;
 }
}

@keyframes light-up-theme-color-three {
 0% {
  box-shadow: 0 1px 10px 5px var(--theme-color-three);
 }
 25% {
  box-shadow: 0 1px 15px 5px var(--theme-color-three);
 }
 50% {
  box-shadow: 0 1px 20px 5px var(--theme-color-three);
 }
 75% {
  box-shadow: 0 1px 25px 5px var(--theme-color-three);
 }
 100% {
  box-shadow: none;
 }
}

@keyframes light-up-theme-color-four {
 0% {
  box-shadow: 0 1px 10px 5px var(--theme-color-four);
 }
 25% {
  box-shadow: 0 1px 15px 5px var(--theme-color-four);
 }
 50% {
  box-shadow: 0 1px 20px 5px var(--theme-color-four);
 }
 75% {
  box-shadow: 0 1px 25px 5px var(--theme-color-four);
 }
 100% {
  box-shadow: none;
 }
}

@keyframes light-up-theme-color-five {
 0% {
  box-shadow: 0 1px 10px 5px var(--theme-color-five);
 }
 25% {
  box-shadow: 0 1px 15px 5px var(--theme-color-five);
 }
 50% {
  box-shadow: 0 1px 20px 5px var(--theme-color-five);
 }
 75% {
  box-shadow: 0 1px 25px 5px var(--theme-color-five);
 }
 100% {
  box-shadow: none;
 }
}

.hidden {
 opacity: 0;
}

.light-bulbs {
 display: flex;
 justify-content: space-between;
 padding: 20px;
 width: 500px;
 margin: 0 auto;
}

.light-bulbs.on .light-bulb {
 animation-duration: 1.1s;
 animation-iteration-count: infinite;
}

.light-bulbs.on .light-bulb.theme-color-one {
 animation-name: light-up-theme-color-one;
}

.light-bulbs.on .light-bulb.theme-color-two {
 animation-name: light-up-theme-color-two;
}

.light-bulbs.on .light-bulb.theme-color-three {
 animation-name: light-up-theme-color-three;
}

.light-bulbs.on .light-bulb.theme-color-four {
 animation-name: light-up-theme-color-four;
}

.light-bulbs.on .light-bulb.theme-color-five {
 animation-name: light-up-theme-color-five;
}

.light-bulb {
 border-radius: 50%;
 height: 30px;
 position: relative;
 transition-duration: 0.4s;
 width: 30px;
 position: relative;
}

.light-bulb .color-setting {
 margin-top: 15px;
 position: absolute;
 top: 100%;
 left: -25%;
 transition-duration: 0.4s;
}

.light-bulb::before {
 content: "";
 position: absolute;
 border: 2px solid #222;
 width: 10px;
 height: 10px;
 background: #222;
 border-top-left-radius: 5px;
 border-top-right-radius: 5px;
 left: 25%;
 top: -12px;
}

.light-bulb::after {
 content: "";
 top: -20px;
 left: 60%;
 position: absolute;
 width: 90px;
 height: 28px;
 border-bottom: 4px solid #222;
 border-radius: 50%;
 z-index: -1;
}

.light-bulb:last-of-type::after {
 border: none;
}

.light-bulb.theme-color-one {
 background: var(--theme-color-one);
}

.light-bulb.theme-color-two {
 background: var(--theme-color-two);
}

.light-bulb.theme-color-three {
 background: var(--theme-color-three);
}

.light-bulb.theme-color-four {
 background: var(--theme-color-four);
}

.light-bulb.theme-color-five {
 background: var(--theme-color-five);
}

.light-bulb-settings {
 background: var(--white);
 color: #333;
 width: 500px;
 margin: 30px auto 0;
 padding: 20px;
 border-radius: 10px;
}

.light-bulb-settings .group {
 align-items: center;
 display: flex;
 margin: 15px 0;
}

.light-bulb-settings .group label {
 flex-basis: 80px;
}

.checkbox-container {
 cursor: pointer;
 width: 43px;
 height: 20px;
 background: var(--grey);
 border-radius: 100px;
 margin-right: 5px;
 position: relative;
 padding: 6px 12px;
 transition-duration: 0.4s;
}

.checkbox-container.active {
 background: var(--black);
}

.checkbox-container.active::after {
 left: 50%;
}

.checkbox-container::after {
 content: "";
 position: absolute;
 width: 25px;
 height: 25px;
 background: var(--white);
 border-radius: 100%;
 left: 5%;
 top: 9%;
 transition-duration: 0.4s;
}

.light-switch {
 opacity: 0;
 visibility: hidden;
}

.interval-control {
 border: 1px solid var(--black);
 border-radius: 5px;
 font-family: inherit;
 font-size: inherit;
 padding: 6px 12px;
}

.color-wheel {
 border: 1px solid var(--black);
 border-radius: 5px;
 cursor: pointer;
 font-family: inherit;
 font-size: 16px;
 margin-top: 10px;
 padding: 6px 12px;
 outline: 0;
}

              
            
!

JS

              
                const settings = document.querySelector(".light-bulb-settings");
const checkBoxContainer = document.querySelector(".checkbox-container");
const lightSwitch = document.querySelector(".light-switch");
const lightSwitchState = document.querySelector(".light-switch-state");
const lightBulbContainer = document.querySelector(".light-bulbs");
const lightBulbs = lightBulbContainer.querySelectorAll(".light-bulb");
const colorWheelBtn = document.querySelector(".color-wheel");
const colorWheels = lightBulbContainer.querySelectorAll(".color-setting");
const lightSwitchTextValues = {
 on: "off",
 off: "on"
};
const toggleProps = {};
const elemActions = {
 switch: () => {
  lightBulbContainer.classList.toggle("on");

  lightSwitchState.textContent =
   lightSwitchTextValues[lightSwitchState.textContent];
 },
 interval: e => {
  const duration = e.target.value;
  lightBulbs.forEach(lightBulb => {
   lightBulb.style.animationDuration = `${duration}s`;
  });
 }
};

settings.addEventListener("change", e => {
 elemActions[e.target.dataset.elem](e);
});

checkBoxContainer.addEventListener("click", e => {
 e.target.classList.toggle("active");
 lightSwitch.click();
});

colorWheelBtn.addEventListener("click", e => {
 colorWheels.forEach(colorWheel => {
  colorWheel.classList.toggle("hidden");
 });
});

lightBulbContainer.addEventListener("input", e => {
 const { themeColor } = e.target.dataset;
 const lightBulb = e.target.parentElement;
 lightBulb.style.setProperty(`--theme-color-${themeColor}`, e.target.value);
});

              
            
!
999px

Console