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>
<button class="button  button--small  button--default">Small button</button>
<button class="button  button--small  button--success">Small success button</button>
<button class="button  button--small  button--warning">Small warning button</button>
<button class="button  button--small  button--danger">Small danger button</button>
<button class="button  button--small  button--info">Small info button</button>
</div>

<div>
<button class="button  button--default">Medium button</button>
<button class="button  button--success">Medium success button</button>
<button class="button  button--warning">Medium warning button</button>
<button class="button  button--danger">Medium danger button</button>
<button class="button  button--info">Medium info button</button>
</div>

<div>
<button class="button  button--large  button--default">Large button</button>
<button class="button  button--large  button--success">Large success button</button>
<button class="button  button--large  button--warning">Large warning button</button>
<button class="button  button--large  button--danger">Large danger button</button>
<button class="button  button--large  button--info">Large info button</button>
</div>

<button class="button  button--default  button--bold">Bold button</button>
<button class="button  button--default  button--upper">Uppercase button</button>

<button class="button  button--default  button--block">Block button</button>
              
            
!

CSS

              
                @import "compass/css3";

// Configuration
$btn-name: 'button' !default;
$btn-hover: lighten 10% !default;
$btn-border:  darken 10% !default; // Set to false for no border
$btn-size-ratio: 1.2 !default;
$btn-schemes: (
  default: #7f8c8d,
  success: #27ae60,
  danger:  #c0392b,
  warning: #f1c40f,
  info:    #2980b9
) !default;

// Color helper 
// 1. Background-color
// 2. On hover
// 3. Border-color
@mixin button-color($color) {
  $everything-okay: true;
  
  // Making sure $color is a color
  @if type-of($color) != color {
    @warn "`#{$color}` is not a color for `button-color`";
    $everything-okay: false;  
  }
  
  // Making sure $btn-hover and $btn-border are 2 items long
  @if length($btn-hover) != 2 
   or length($btn-border) != 2 {
    @warn "Both `$btn-hover` and `$btn-border` should be two items long for `button-color`.";
    $everything-okay: false;  
  }
  
  // Making sure first items from $btn-hover and $btn-border are valid functions
  @if not function-exists(nth($btn-hover, 1)) 
   or not function-exists(nth($btn-border, 1)) {
    @warn "Either `#{nth($btn-hover, 1)}` or `#{nth($btn-border, 1)}` is not a valid function for `button-color`.";
    $everything-okay: false;  
  }
  
  // Making sure second items from $btn-hover and $btn-border are percentages
  @if type-of(nth($btn-hover, 2)) != number 
   or type-of(nth($btn-border, 2)) != number {
    @warn "Either `#{nth($btn-hover, 2)}` or `#{nth($btn-border, 2)}` is not a valid percentage for `button-color`.";
    $everything-okay: false;  
  }
  
  // If there is no mistake
  @if $everything-okay == true {
    background-color: $color; // 1
  
    &:hover,
    &:active { // 2
      background: call(nth($btn-hover, 1), $color, nth($btn-hover, 2));
    }  
  
    @if $btn-border != false { // 3
      border-color: call(nth($btn-border, 1), $color, nth($btn-border, 2));
    }
  }
}

// Default class
// 1. Border or not border?
// 2. Large modifier
// 3. Small modifier
// 4. Bold modifier
// 5. Block modifier
// 6. Uppercase modifier
// 7. Color themes modifier
.#{$btn-name} {
  // Default styles
  padding: .5em;
  margin-bottom: 1em;
  color: #fff;
  transition: background .15s;
  box-shadow: inset 0 1px rgba(255, 255, 255, .2);
  border-radius: .15em;
  border: if($btn-border != false, 1px solid, none); // 1
  
  // Modifiers
  &--large { // 2
    font-size: 1em * $btn-size-ratio;
  }
  
  &--small { // 3
    font-size: 1em / $btn-size-ratio;
  }

  &--bold { // 4
    font-weight: bold;
  }
  
  &--block { // 5
    display: block;
    width: 100%;
  }  
  
  &--upper { // 6
    text-transform: uppercase;
  }
  
  @each $key, $value in $btn-schemes { // 7
    &--#{$key} {
      @include button-color($value);
    }
  }
}

// Demo
body {
  padding: 1em;
}
              
            
!

JS

              
                
              
            
!
999px

Console