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.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <div class="tools">
  <label for="font-picker-size">Font size</label>
  <input type="range" id="font-picker-size" value="125" min="80" max="300">
  <label for="color-picker-primary">Primary Color</label>
  <input type="color" id="color-picker-primary" value="#b30027">
  <label for="color-picker-contrast">Contrast Color</label>
  <input type="color" id="color-picker-contrast" value="#ffffff">

<div class="template">
  <div class="primary--fill masthead">
    <h1 class="contrast--text">Using CSS Custom Properties and the CSSOM to create real time theme previews</h1>
  <div class="body">
    <h2 class="primary--text">
      My themed page
     <p>Bacon ipsum dolor amet swine t-bone leberkas, pork belly strip steak tongue shankle bresaola ball tip ribeye ham pork loin ham hock. Pork belly capicola ground round t-bone chicken doner beef ribs tail pork chop tenderloin swine flank ham. Jerky sirloin tongue <a class="primary--text" href="#">spare ribs t-bone</a> shoulder short ribs chuck frankfurter. Shoulder pig capicola landjaeger beef ribs, pork loin short ribs jerky salami cupim. Beef ribs bacon tongue, ribeye short loin turducken swine sirloin porchetta capicola picanha ball tip cupim shank frankfurter. Shank bacon biltong, flank beef turkey porchetta sausage meatloaf pastrami shankle tenderloin spare ribs short ribs pork belly.</p>

    <a class="button primary--fill contrast--text" href="#">Button</a>

    <p>Bresaola bacon shank salami pancetta drumstick andouille shoulder capicola hamburger corned beef prosciutto t-bone chuck. <a class="primary--text" href="#">Biltong sausage boudin, brisket turducken</a> doner venison landjaeger salami picanha tri-tip pork belly spare ribs short ribs. Turkey pork belly shoulder boudin tail, beef pork loin ground round spare ribs ribeye tri-tip landjaeger bresaola. Cow shankle rump tail. Ground round ham hock capicola landjaeger sausage. Ribeye pig meatball, spare ribs pancetta capicola doner salami.</p>
              :root {
  --theme-contrast: #ffffff;
  --theme-primary: #b30027;
  --theme-font-size: 125%;
  --unsupported-message-display: none;

.template {
  font-size: var(--theme-font-size);

.primary--text {
  color: var(--theme-primary);

.primary--fill {
  background-color: var(--theme-primary);

.contrast--text {
  color: var(--theme-contrast);

.contrast--fill {
  background-color: var(--theme-contrast);

body {
  font: 100% / 1.5 Georgia;
  margin: 0;
  margin: 0;

p {
  margin: 3em 0;

.masthead {
  padding: 12% 2em;
  text-align: center;
  background-image: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,0.3));

.body {
  margin: auto;
  max-width: 760px;
  padding: 2em;

.button {
  margin: 0;
  padding: .5em 2em;
  border-radius: .25em;
  text-decoration: none;
  box-shadow: 0 .1em .2em 0em rgba(0,0,0,0.5);
  border-bottom: .15em solid rgba(0,0,0,0.25);

.button:hover {
  background-image: linear-gradient(

.tools {
  position: fixed;
  background: rgba(255,255,255,.75);
  padding: 1em;
  margin: .5em;
  border-radius: .25em;
  max-width: 20em;

.tools > * {
  display: inline-block;

.tools label {
  min-width: 9em;
  max-width: 11em;
              let primaryColorPicker = document.getElementById('color-picker-primary');
let contrastColorPicker = document.getElementById('color-picker-contrast');
let fontSizePicker = document.getElementById('font-picker-size');

function setThemeVar(name, value, unit) {
  let rootStyles = document.styleSheets[0].cssRules[0].style;
  rootStyles.setProperty('--theme-' + name, value + (unit || ''));

primaryColorPicker.addEventListener('input', function(e){

contrastColorPicker.addEventListener('input', function(e){

fontSizePicker.addEventListener('input', function(e){
  setThemeVar('font-size',, '%');

🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.