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

              
                <!-- Such classes. Much Redundant. So button. Wow.

  <button class="button button--green button--rounded button--large">
    Buttin
  </button> 

-->

<h2>Individual Modifiers</h2>
<!-- Less Redudant, still flexible -->
<button class="button">Button</button>

<button class="button -green">Green</button>

<button class="button -rounded">Rounded</button>

<button class="button -green -rounded -large">Multi-class</button>

<button class="button overrides -disable">Override Class</button>

<h2>Saved Variations</h2>
<!-- The one class wonder! -->
<button class="button--save">Save</button>
<button class="button--delete">Delete</button>


              
            
!

CSS

              
                /* 
  Declare all styles using placeholder selectors using the same old BEM syntax we all know and love.
*/

%button {
  background: #45beff;
  border: none;
  padding: 1em 2em;
  font-size: 16px;
  
  &:hover {
    opacity: 0.75;
  }
}

%button--green {
  background: #3efa95;
}

%button--red {
  background: #ff3a6a;
}


%button--large {
  font-size:20px;
}

%button--rounded {
  border-radius: 10px;
}


/* 
  Assemble our button, exposing modifiers we plan on using in our markup by extending placeholder selectors 
*/

.button {
    @extend %button;
    
    /* 
       Prefixing modifiers with '-', and only decalring them within the scope of what they are modifying ensures that they'll never cause a conflict
    */
  
    &.-green {
        @extend %button--green;
    }
  
    %button--red {
      background: #ff3a6a;
    }
   
    &.-large {
        @extend %button--large;
    }
   
    &.-rounded {
        @extend %button--rounded;
    }
}


/*
  Save even more clutter by saving commonly used modifier combinations as new modifier class
*/

.button--save {
  @extend %button;
  @extend %button--large;
  @extend %button--rounded;
  @extend %button--green;
}

.button--delete {
  @extend %button;
  @extend %button--large;
  @extend %button--rounded;
  @extend %button--red;
}



/*
  If you really need to override something, (like the changing opacity on hover), you could create override rules like so:
*/

.overrides {
  &.-disable {
    opacity: 0.25;
  }
}






// DEMO STYLES
body {
  font-family: sans-serif;
}
              
            
!

JS

              
                
              
            
!
999px

Console