cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

Quick-add: + add another resource

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.

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.

            
              
<h1>Using CSS Variables and currentColor to theme a site</h1>
<label for="colors">Change the Color:</label>
<input type="range" id="colors" min="0" max="360" step=".1" value="0">
<div id="result"></div>
<label for="colors">A Label:</label>
<input type="text" id="textbox" value="A Text Input">
<button>A Button</button>
<a href="/">A link</a>
            
          
!
            
              :root {
  --color: hsl(0, var(--saturation), var(--lightness));
  --saturation: 60%;
  --lightness: 40%;
  color: var(--color);
}
#result {
  background: currentColor;
  width: 100%;
  height: 2rem;
}

body {
  padding: 2rem;
  background: hsl(220, 12%, 89%);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
* {
  box-sizing: border-box;
  margin: 1rem 0;
  color: currentColor;
  border-color: currentColor;
}
button {
  -moz-appearance: none;
  -ms-appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: .2rem solid;
  font-size: 1rem;
  display: block;
  padding: .5rem 1rem;
  border-radius: .5rem;
}



h1 {
  color: #39393b;
  font-weight: 400;
  font-size: 1.5rem;
  margin-top: 0;
}
input[type=text] {
  display: block;
  margin-top: .25rem;
  height: 2.6rem;
  font-size: 1rem;
  
  -moz-appearance: none;
  -ms-appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: none;
  border: .15rem solid #69696b;
  padding: .5rem;
}



/*input range styles*/
input[type=range] {
  -moz-appearance: none;
  -ms-appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 2rem;
  background: linear-gradient(to right,
    hsl(0, var(--saturation), var(--lightness)),
    hsl(10, var(--saturation), var(--lightness)),
    hsl(20, var(--saturation), var(--lightness)),
    hsl(30, var(--saturation), var(--lightness)),
    hsl(40, var(--saturation), var(--lightness)),
    hsl(50, var(--saturation), var(--lightness)),
    hsl(60, var(--saturation), var(--lightness)),
    hsl(70, var(--saturation), var(--lightness)),
    hsl(80, var(--saturation), var(--lightness)),
    hsl(90, var(--saturation), var(--lightness)),
    hsl(100, var(--saturation), var(--lightness)),
    hsl(110, var(--saturation), var(--lightness)),
    hsl(120, var(--saturation), var(--lightness)),
    hsl(130, var(--saturation), var(--lightness)),
    hsl(140, var(--saturation), var(--lightness)),
    hsl(150, var(--saturation), var(--lightness)),
    hsl(160, var(--saturation), var(--lightness)),
    hsl(170, var(--saturation), var(--lightness)),
    hsl(180, var(--saturation), var(--lightness)),
    hsl(190, var(--saturation), var(--lightness)),
    hsl(200, var(--saturation), var(--lightness)),
    hsl(210, var(--saturation), var(--lightness)),
    hsl(220, var(--saturation), var(--lightness)),
    hsl(230, var(--saturation), var(--lightness)),
    hsl(240, var(--saturation), var(--lightness)),
    hsl(250, var(--saturation), var(--lightness)),
    hsl(260, var(--saturation), var(--lightness)),
    hsl(270, var(--saturation), var(--lightness)),
    hsl(280, var(--saturation), var(--lightness)),
    hsl(290, var(--saturation), var(--lightness)),
    hsl(300, var(--saturation), var(--lightness)),
    hsl(310, var(--saturation), var(--lightness)),
    hsl(320, var(--saturation), var(--lightness)),
    hsl(330, var(--saturation), var(--lightness)),
    hsl(340, var(--saturation), var(--lightness)),
    hsl(350, var(--saturation), var(--lightness)),
    hsl(360, var(--saturation), var(--lightness)));
  
  margin-top: .25rem;
}
input[type=range]::-ms-track {
  width: 100%;
  cursor: pointer;
  background: transparent; 
  border-color: transparent;
  color: transparent;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  border: .15rem solid currentColor;
  box-shadow: 0px 0px 3px rgba(0, 0, 0, .65);
  height: 2.6rem;
  width: 16px;
  border-radius: 0rem;
  background: transparent;
  cursor: pointer;
}
input[type=range]::-moz-range-thumb {
  border: .15rem solid currentColor;
  box-shadow: 0px 0px 3px rgba(0, 0, 0, .65);
  height: 2.6rem;
  width: 16px;
  border-radius: 0rem;
  background: transparent;
  cursor: pointer;
}
input[type=range]::-ms-thumb {
  border: .15rem solid currentColor;
  box-shadow: 0px 0px 3px rgba(0, 0, 0, .65);
  height: 2.6rem;
  width: 16px;
  border-radius: 0rem;
  background: transparent;
  cursor: pointer;
}

            
          
!
            
              var colors = document.getElementById('colors');
var docStyle = document.documentElement.style;

colors.addEventListener('input', function(e) {
  var value = e.currentTarget.value;
  //change to --color to latch into CSS Variables for a more precise implementation
  docStyle.setProperty('color', 'hsl(' + (value) + ', 60%, 40%)');
})
            
          
!
999px
Loading ..................

Console