Pen Settings

HTML

CSS

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

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

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.

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

              
                - var btns = ['primary','secondary','success','danger','warning','info','light','dark','link','lg','sm','brand-primary','brand-secondary','brand-tertiary'];
.container
  .card.mt-5
    .card-header
      h1.display-4 Auto Custom Bootstrap 4 Buttons
    .card-body
      each val in btns
        button(class='btn btn-' + val)= val
              
            
!

CSS

              
                //Colors - Any Colors You Want
$colors: (
  primary: #00a9e7,
  secondary: #09e3fe,
  success: #37ff3b,
  danger: #ee3426,
  warning: #e4de33,
  info: #00a9e7,
  light: #eee,
  dark: #444,
  brand-primary: #420dab, 
  brand-secondary: #36418c, 
  brand-tertiary: #c0d6e4
);

//Dark or Light background to determine text color
@function text-color($color) {
  @if (lightness($color) > 50) {
    @return #000; // Lighter backgorund, return dark color
  } @else {
    @return #fff; // Darker background, return light color
  }
}

//Bootstrap Button - Make Any Customizations Here
@mixin custom-bootstrap-btns {
  //Generates the class names via the $colors Map
  @each $className in $colors {
    .btn-#{nth($className, 1)} {
      $buttonColor: nth($className, 2);
      background: $buttonColor;
      color: text-color($buttonColor);
      border-color: darken($buttonColor, 5%);
      &:hover {
        background: lighten($buttonColor, 10%);
        color: text-color(lighten($buttonColor, 10%));
        border-color: $buttonColor;
      }
    }
  }
  //Button Sizes
  .btn {
    &-lg {
      //Any Size Customizations here
    }
    &-sm {
      //Any Size Customizations here
    }
    &-link {
      //Any Customizations here
    }
  }
}

//Boostrap Custom Buttons Mixin Call
@include custom-bootstrap-btns;

//Layout for Pen
body {
  background: #222;
}
button {
  margin: 10px;
  cursor: pointer;
}
              
            
!

JS

              
                //Auto Custom Bootstrap 4 Buttons

//Created a Mixn so it can be stored in a partial, but doesn't have to be.

//The Mixin generates all the classes you need via the @each function

//Gives you complete control on how you want your custom buttons to look like, while using all the lovely bootstrap class names for buttons. Go ahead and play with the CSS to create your own custom buttons

//I had fun making this
              
            
!
999px

Console