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

              
                //-
    Experimenting with using Pug mixins with parameters to have a sort of props-based system without needing a JS framework. 

    These sort of components can easily be translated to any JS framework
    Feedback: @wolfr_2 on Twitter

//-
    Mixin Icon - Render an icon from Mono icons

    @param {Object} parameters
    @param {string} icon - icon name

mixin icon(name)
    span.c-icon(class="c-icon--"+name)
        i.mi(class="mi-"+name)

//-
    Mixin Button - Create a button

    @param {Object} parameters
    @param block content - Use pug block for button label
    @param {string} buttonType - button type
    @param {boolean} href - turns the button into an <a> element if true
    @param {string} icon - icon name - passes icon to icon mixin
    @param {string} skin - the skin of the button (primary, secondary)
    @param {string} layout - the layout of the button (text-icon, icon-only)

mixin button({buttonType = "button", label, href, icon, skin = "secondary", layout})
    - var icononlyclass = ""
    - if (layout == "icon-only") icononlyclass = " c-button--icon-only"
    - var classList = "c-button c-button--"+skin+" "+icononlyclass

    if href
        a(href=href class=classList)&attributes(attributes)
            +button-inner-layout(icon, layout)
                if block
                    block
                else
                    | No label provided
                    
    else
        button(type=buttonType class=classList)&attributes(attributes)
            +button-inner-layout(icon, layout)
                if block
                    block
                else
                    | No label provided

mixin button-inner-layout(icon, layout)
    span.c-button__content
        if !layout
            if icon
                +icon(icon)
                span.c-button__label
                    block
            else
                span.c-button__label
                    block
        else if layout === "text-icon"
            span.c-button__label
                block
            +icon(icon)
        else if layout === "icon-only"
            +icon(icon)
            .u-sr-only
                block

// Examples of our buttons
.u-m-4
    p.u-mb-2
        +button({ icon: 'add', skin: 'primary' }) Add
        +button({ icon: 'add', skin: 'primary' })(disabled) Add

    p.u-mb-2
        +button({ icon: 'edit' })(disabled) Edit
        +button({ icon: 'edit' }) Edit

    p.u-mb-2
        +button({ icon: 'edit', layout: 'icon-only' })(disabled) Edit
        +button({ icon: 'edit', layout: 'icon-only' }) Edit

    p.u-mb-2
        +button({ href: 'https://www.google.com/' })(disabled) Link to Google
        +button({ href: 'https://www.google.com/' }) Link to Google

    p.u-mb-2
        +button({ icon: 'chevron-down', layout: 'text-icon' })(disabled) Actions
        +button({ icon: 'chevron-down', layout: 'text-icon' }) Actions

    p.u-mb-2
        +button({ buttonType: 'submit' })(disabled) Submit
        +button({ buttonType: 'submit' }) Submit

    p.u-mb-2
        +button({})(class="extra-class")
            | Button 1 - with an extra class
        +button({})(disabled)
            | Button 2 
        +button({})

              
            
!

CSS

              
                
/* Colors (SCSS)
   ========================================================================== */

$color-gray-50:   #F2F2F2;
$color-gray-100:  #E6E6E6;
$color-gray-150:  #D9D9D9;
$color-gray-200:  #CCCCCC;
$color-gray-300:  #B3B3B3;
$color-gray-400:  #999999;
$color-gray-500:  #808080;
$color-gray-550:  #737373;
  
$color-gray-600:  #666666;
$color-gray-700:  #4D4D4D;
$color-gray-800:  #333333;
$color-gray-850:  #262626;
$color-gray-900:  #1A1A1A;
$color-gray-950:  #0D0D0D;

$color-blue-600:  #5584EB;

/* Base elements
   ========================================================================== */

html {
  font-size: 62.5%;
}

body {
  font-size: 1.6rem;
  color: $color-gray-700;
}

/* Icon
   ========================================================================== */

.c-icon {
  font-size: 2rem;
}
  
/* Buttons
   ========================================================================== */

.c-button {
  padding: 0.8rem 1.4rem;
  display: inline-block;
  vertical-align: middle;
  appearance: none;
  border-radius: 0.3rem;
  text-decoration: none;
  border: none;
  font-size: 1.6rem;
  color: $color-gray-700;
  background: $color-gray-50;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}

a.c-button {
  padding-top: 1.2rem;
  padding-bottom: 1.2rem;
}

.c-button[type="submit"] {
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.c-button--icon-only {
  padding: 0.8rem 1.1rem;
}

.c-button__content {
  display: flex;
  align-items: center;
}

.c-button:not(.c-button--icon-only) .c-button__content .c-icon {
    margin-right: .4rem;
}

.c-button__content .c-button__label + .c-icon {
    margin-right: 0;
    margin-left: .4rem;
}

.c-button--secondary {
  &,
  &:link,
  &:visited {
    color: $color-gray-700;
    background: $color-gray-50;
  }
  &:hover {
    background: lighten($color-gray-50, 2.5%);
    transition: 0.18s ease-in-out background;
  }

}

.c-button--primary {
  &,
  &:link,
  &:visited {
    color: #FFF;
    background: $color-blue-600;
  }
  &:hover {
    background: lighten($color-blue-600, 5%);
    transition: 0.18s ease-in-out background;
  }
}

.c-button[disabled] {
    opacity: .3;
}

a.c-button[disabled] {
    pointer-events: none;
    cursor: default;
}

/* Spacing utilities
   ========================================================================== */

$spacing-var: .8rem;

.u-mb-2 {
  margin-bottom: $spacing-var*2;
}

.u-m-4 {
  margin: $spacing-var*4;
}

/* Generic utilities
   ========================================================================== */

.u-sr-only {
  position: absolute;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

// For demo purposes
.extra-class {
    color: purple;
}

              
            
!

JS

              
                
              
            
!
999px

Console