123

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.

            
               <button id="background-toggle" class="toggle">Toggle<br />Bkg.</button>

<h1>States</h1>


<hr />


<h2>Solid Treatment, All Sizes</h2>

<h3>Small</h3>

<button class="button button--primary button--small button--solid">Save</button>

<button class="button button--secondary button--small button--solid">Save</button>

<button class="button button--tertiary button--small button--solid">Save</button>

<h3>Medium</h3>

<button class="button button--primary button--medium button--solid">Save</button>

<button class="button button--secondary button--medium button--solid">Save</button>

<button class="button button--tertiary button--medium button--solid">Save</button>

<h3>Large</h3>

<button class="button button--primary button--large button--solid">Save</button>

<button class="button button--secondary button--large button--solid">Save</button>

<button class="button button--tertiary button--large button--solid">Save</button>


<hr />


<h2>Hollow Treatment, All Sizes</h2>

<h3>Small</h3>

<button class="button button--primary button--small button--hollow">Save</button>

<button class="button button--secondary button--small button--hollow">Save</button>

<button class="button button--tertiary button--small button--hollow">Save</button>

<h3>Medium</h3>

<button class="button button--primary button--medium button--hollow">Save</button>

<button class="button button--secondary button--medium button--hollow">Save</button>

<button class="button button--tertiary button--medium button--hollow">Save</button>

<h3>Large</h3>

<button class="button button--primary button--large button--hollow">Save</button>

<button class="button button--secondary button--large button--hollow">Save</button>

<button class="button button--tertiary button--large button--hollow">Save</button>


<hr />


<h2>Icon Treatment, All Sizes and Fills</h2>

<h3>Small, Solid</h3>

<button class="button button--primary button--small button--solid button--icon">
  <svg aria-hidden="true" class="icon-download"><use xlink:href="#icon-download"></use></svg>
  <span>Download</span>
</button>

<button class="button button--secondary button--small button--solid button--icon">
  <svg aria-hidden="true" class="icon-download"><use xlink:href="#icon-download"></use></svg>
  <span>Download</span>
</button>

<button class="button button--tertiary button--small button--solid button--icon">
  <svg aria-hidden="true" class="icon-download"><use xlink:href="#icon-download"></use></svg>
  <span>Download</span>
</button>

<h3>Medium, Solid</h3>

<button class="button button--primary button--medium button--solid button--icon">
  <svg aria-hidden="true" class="icon-download"><use xlink:href="#icon-download"></use></svg>
  <span>Download</span>
</button>

<button class="button button--secondary button--medium button--solid button--icon">
  <svg aria-hidden="true" class="icon-download"><use xlink:href="#icon-download"></use></svg>
  <span>Download</span>
</button>

<button class="button button--tertiary button--medium button--solid button--icon">
  <svg aria-hidden="true" class="icon-download"><use xlink:href="#icon-download"></use></svg>
  <span>Download</span>
</button>

<h3>Large, Solid</h3>

<button class="button button--primary button--large button--solid button--icon">
  <svg aria-hidden="true" class="icon-download"><use xlink:href="#icon-download"></use></svg>
  <span>Download</span>
</button>

<button class="button button--secondary button--large button--solid button--icon">
  <svg aria-hidden="true" class="icon-download"><use xlink:href="#icon-download"></use></svg>
  <span>Download</span>
</button>

<button class="button button--tertiary button--large button--solid button--icon">
  <svg aria-hidden="true" class="icon-download"><use xlink:href="#icon-download"></use></svg>
  <span>Download</span>
</button>

<h3>Small, Hollow</h3>

<button class="button button--primary button--small button--hollow button--icon">
  <svg aria-hidden="true" class="icon-download"><use xlink:href="#icon-download"></use></svg>
  <span>Download</span>
</button>

<button class="button button--secondary button--small button--hollow button--icon">
  <svg aria-hidden="true" class="icon-download"><use xlink:href="#icon-download"></use></svg>
  <span>Download</span>
</button>

<button class="button button--tertiary button--small button--hollow button--icon">
  <svg aria-hidden="true" class="icon-download"><use xlink:href="#icon-download"></use></svg>
  <span>Download</span>
</button>

<h3>Medium, Hollow</h3>

<button class="button button--primary button--medium button--hollow button--icon">
  <svg aria-hidden="true" class="icon-download"><use xlink:href="#icon-download"></use></svg>
  <span>Download</span>
</button>

<button class="button button--secondary button--medium button--hollow button--icon">
  <svg aria-hidden="true" class="icon-download"><use xlink:href="#icon-download"></use></svg>
  <span>Download</span>
</button>

<button class="button button--tertiary button--medium button--hollow button--icon">
  <svg aria-hidden="true" class="icon-download"><use xlink:href="#icon-download"></use></svg>
  <span>Download</span>
</button>

<h3>Large, Hollow</h3>

<button class="button button--primary button--large button--hollow button--icon">
  <svg aria-hidden="true" class="icon-download"><use xlink:href="#icon-download"></use></svg>
  <span>Download</span>
</button>

<button class="button button--secondary button--large button--hollow button--icon">
  <svg aria-hidden="true" class="icon-download"><use xlink:href="#icon-download"></use></svg>
  <span>Download</span>
</button>

<button class="button button--tertiary button--large button--hollow button--icon">
  <svg aria-hidden="true" class="icon-download"><use xlink:href="#icon-download"></use></svg>
  <span>Download</span>
</button>


<hr />


<h2>Disabled Treatment, All Fills</h2>

<h3>Solid</h3>

<button disabled class="button button--primary button--medium button--solid">Disabled</button>

<button disabled class="button button--secondary button--medium button--solid button--icon">
  <svg aria-hidden="true" class="icon-download"><use xlink:href="#icon-download"></use></svg>
  <span>Download</span>
</button>

<h3>Hollow</h3>

<button disabled class="button button--tertiary button--medium button--hollow">Disabled</button>

<button disabled class="button button--primary button--medium button--hollow button--icon">
  <svg aria-hidden="true" class="icon-download"><use xlink:href="#icon-download"></use></svg>
  <span>Download</span>
</button>


<hr />


<h2>Busy Treatment</h2>

<h3>Solid</h3>

<button aria-busy="true" class="button button--primary button--medium button--solid">Busy</button>

<button aria-busy="true" class="button button--secondary button--medium button--solid">Busy</button>

<button aria-busy="true" class="button button--tertiary button--medium button--solid">Busy</button>

<button aria-busy="true" class="button button--primary button--medium button--solid button--icon">
  <svg aria-hidden="true" class="icon-download"><use xlink:href="#icon-download"></use></svg>
  <span>Busy</span>
</button>

<button aria-busy="true" class="button button--secondary button--medium button--solid button--icon">
  <svg aria-hidden="true" class="icon-download"><use xlink:href="#icon-download"></use></svg>
  <span>Busy</span>
</button>

<button aria-busy="true" class="button button--tertiary button--medium button--solid button--icon">
  <svg aria-hidden="true" class="icon-download"><use xlink:href="#icon-download"></use></svg>
  <span>Busy</span>
</button>

<h3>Hollow</h3>

<button aria-busy="true" class="button button--primary button--medium button--hollow">Busy</button>

<button aria-busy="true" class="button button--secondary button--medium button--hollow">Busy</button>

<button aria-busy="true" class="button button--tertiary button--medium button--hollow">Busy</button>

<button aria-busy="true" class="button button--primary button--medium button--hollow button--icon">
  <svg aria-hidden="true" class="icon-download"><use xlink:href="#icon-download"></use></svg>
  <span>Busy</span>
</button>

<button aria-busy="true" class="button button--secondary button--medium button--hollow button--icon">
  <svg aria-hidden="true" class="icon-download"><use xlink:href="#icon-download"></use></svg>
  <span>Busy</span>
</button>

<button aria-busy="true" class="button button--tertiary button--medium button--hollow button--icon">
  <svg aria-hidden="true" class="icon-download"><use xlink:href="#icon-download"></use></svg>
  <span>Busy</span>
</button>
            
          
!
            
              ///////////////////////////////
// ELEMENT LOGIC             //
// Element starts on line 53 //
///////////////////////////////

// Breakpoints:
$bp-lap: 37.5em;  // 600px @ 16px

// Background variables
$background-light: #fefbef;
$background-dark: #403f3c;

// Color variables
$type-light: $background-light;
$type-dark: $background-dark;
$button-color-primary-light: #ff4136;
$button-color-secondary-light: #357edd;
$button-color-tertiary-light: #808080;
$button-color-primary-dark: #ff6347;
$button-color-secondary-dark: #1e90ff;
$button-color-tertiary-dark: #939393;

// Transform variables
$button-bounce: scale(0.98);

// Transition variables
$button-transition-duration: 300ms;
$button-cycle-busy: 2s ease-in-out infinite;

// Border variables
$button-border-width-thin: 2px;
$button-border-width-thick: 3px;

// Animation
@keyframes button-busy {
  0% { opacity: 0.2; }
  50% { opacity: 0.4; }
  100% { opacity: 0.2; }
}








/////////////////////
// ELEMENT STYLING //
/////////////////////

// Declared as a class so we can easily apply it to both `<button>` and `<input type="button">`
.button {

  /////////////////////
  // CORE FORMATTING //
  /////////////////////
  background-color: transparent;
  border: 0;
  color: $type-light;
  font-family: 'Open Sans', sans-serif;
  font-weight: 600;
  line-height: 1;
  margin-top: 1.5rem;
  transition:
   background-color $button-transition-duration, // Solid buttons
   border-color $button-transition-duration, // Hollow buttons
   box-shadow ($button-transition-duration / 2); // Focused buttons
  width: 100%; // Large, mobile-friendly touch target

  // States
  // All states share these core properties
  &:focus {
    outline: none; // Make sure every priority has a visually distinct focus style!
  }

  // Make buttons feel "tappy"
  &:active {
    transform: $button-bounce;
    transition: none;
  }

  // Disabled styles use the`!important` qualifier because they are a "fixed" trump state that should not be manipulated until the reason for disabling the element has been satisfied: https://csswizardry.com/2016/05/the-importance-of-important/ 
  &[aria-busy="true"] {
    animation: button-busy $button-cycle-busy !important;
    cursor: not-allowed !important;
    pointer-events: none !important;

    &:focus {
      box-shadow: none !important;
    }

    &:active {
      transform: none !important;
    }
  }

  &[disabled] {
    cursor: not-allowed !important;
    opacity: 0.3 !important;
    pointer-events: none !important;
  }

  // Contexts
  // All contexts share these core properties
  .background--dark & {
    color: $type-dark;
  }

  // Media Queries
  @media (min-width: $bp-lap) {
    width: auto; // Smaller buttons on larger screens
    padding-left: 2rem;
    padding-right: 2rem;
    margin-left: 1rem;
    margin-right: 1rem;
  }

  ////////////////
  // PRIORITIES //
  ////////////////
  // Primary buttons
  // `#{&}` interpolates the ampersand selector, letting you target multiple classes on the same element: https://webdesign.tutsplus.com/tutorials/all-you-ever-need-to-know-about-sass-interpolation--cms-21375  
  &--primary#{&}--solid,
  &--primary#{&}--hollow {

    // States
    &:focus {
      box-shadow:
       0 0 0 $button-border-width-thick $background-light,
       0 0 0 ($button-border-width-thin * 2.5) $button-color-primary-light;
    }

    // Contexts
    .background--dark & {
      &:focus {
        box-shadow:
         0 0 0 $button-border-width-thick $background-dark,
         0 0 0 ($button-border-width-thin * 2.5) $button-color-primary-light;
      }
    }
  }

  &--primary#{&}--solid {
    background-color: $button-color-primary-light;

    // States
    &:hover {
      background-color: lighten($button-color-primary-light, 7%);
    }

    &:active {
      background-color: darken($button-color-primary-light, 7%);
    }

    &[disabled] {
      &:hover {
        background-color: $button-color-primary-light !important;
      }
    }
  }

  &--primary#{&}--hollow {
    color: $button-color-primary-light;
    border: $button-border-width-thick solid $button-color-primary-light;

    // States
    &:hover {
      border-color: lighten($button-color-primary-light, 7%);
      color: lighten($button-color-primary-light, 7%);
    }

    &:active {
      border-color: darken($button-color-primary-light, 7%);
      color: darken($button-color-primary-light, 7%);
    }

    &[disabled] {
      &:hover {
        color: $button-color-primary-light;
        border: $button-border-width-thick solid $button-color-primary-light;
      }
    }
  }

  // Secondary buttons
  &--secondary#{&}--solid,
  &--secondary#{&}--hollow {

    // States
    &:focus {
      box-shadow:
       0 0 0 $button-border-width-thick $background-light,
       0 0 0 ($button-border-width-thin * 2.5) $button-color-secondary-light;
    }

    // Contexts
    .background--dark & {
      &:focus {
        box-shadow:
         0 0 0 $button-border-width-thick $background-dark,
         0 0 0 ($button-border-width-thin * 2.5) $button-color-secondary-light;
      }
    }
  }

  &--secondary#{&}--solid {
    background-color: $button-color-secondary-light;

    // States
    &:hover {
      background-color: lighten($button-color-secondary-light, 7%);
    }

    &:active {
      background-color: darken($button-color-secondary-light, 7%);
    }

    &[disabled] {
      &:hover {
        background-color: $button-color-secondary-light !important;
      }
    }

    // Contexts
    .background--dark & {
      background-color: $button-color-secondary-dark;

      // States
      &:hover {
        background-color: lighten($button-color-secondary-dark, 7%);
      }

      &:active {
        background-color: darken($button-color-secondary-dark, 7%);
      }

      &[disabled] {
        &:hover {
          background-color: $button-color-secondary-light !important;
          opacity: 0.2 !important;
        }
      }
    }
  }

  &--secondary#{&}--hollow {
    color: $button-color-secondary-light;
    border: $button-border-width-thick solid $button-color-secondary-light;

    // States
    &:hover {
      border-color: lighten($button-color-secondary-light, 7%);
      color: lighten($button-color-secondary-light, 7%);
    }

    &:active {
      border-color: darken($button-color-secondary-light, 7%);
      color: darken($button-color-secondary-light, 7%);
    }

    &[disabled] {
      &:hover {
        color: $button-color-secondary-light;
        border: $button-border-width-thick solid $button-color-secondary-light;
      }
    }

    // Contexts
    .background--dark & {
      color: $button-color-secondary-dark;
      border: $button-border-width-thick solid $button-color-secondary-dark;

      // States
      &:hover {
        border-color: lighten($button-color-secondary-light, 14%);
        color: lighten($button-color-secondary-light, 14%);
      }

      &:active {
        border-color: darken($button-color-secondary-light, 14%);
        color: darken($button-color-secondary-light, 14%);
      }

      &[disabled] {
        &:hover {
          color: $button-color-secondary-dark;
          border: $button-border-width-thick solid $button-color-secondary-dark;
        }
      }
    }
  }

  // Tertiary buttons
  &--tertiary#{&}--solid,
  &--tertiary#{&}--hollow {

    // States
    &:focus {
      box-shadow:
       0 0 0 $button-border-width-thick $background-light,
       0 0 0 ($button-border-width-thin * 2.5) $button-color-tertiary-light;
    }

    // Contexts
    .background--dark & {
      &:focus {
        box-shadow:
         0 0 0 $button-border-width-thick $background-dark,
         0 0 0 ($button-border-width-thin * 2.5) $button-color-tertiary-light;
      }
    }
  }

  &--tertiary#{&}--solid {
    background-color: $button-color-tertiary-light;

    // States
    &:hover {
      background-color: lighten($button-color-tertiary-light, 7%);
    }

    &:active {
      background-color: darken($button-color-tertiary-light, 7%);
    }

    &[disabled] {
      &:hover {
        background-color: $button-color-tertiary-light !important;
      }
    }

    // Contexts
    .background--dark & {
      background-color: $button-color-tertiary-dark;

      // States
      &:hover {
        background-color: lighten($button-color-tertiary-dark, 7%);
      }

      &:active {
        background-color: darken($button-color-tertiary-dark, 7%);
      }

      &[disabled] {
        &:hover {
          background-color: $button-color-tertiary-dark !important;
        }
      }
    }
  }

  &--tertiary#{&}--hollow {
    color: $button-color-tertiary-light;
    border: $button-border-width-thick solid $button-color-tertiary-light;

    // States
    &:hover {
      border-color: lighten($button-color-tertiary-light, 7%);
      color: lighten($button-color-tertiary-light, 7%);
    }

    &:active {
      border-color: darken($button-color-tertiary-light, 7%);
      color: darken($button-color-tertiary-light, 7%);
      transform: $button-bounce;
      transition: none;
    }

    &[disabled] {
      &:hover {
        color: $button-color-tertiary-light;
        border: $button-border-width-thick solid $button-color-tertiary-light;
      }
    }

    // Contexts
    .background--dark & {
      color: $button-color-tertiary-dark;
      border: $button-border-width-thick solid $button-color-tertiary-dark;

      // States
      &:hover {
        border-color: lighten($button-color-tertiary-light, 21%);
        color: lighten($button-color-tertiary-light, 21%);
      }

      &:active {
        border-color: darken($button-color-tertiary-light, 21%);
        color: darken($button-color-tertiary-light, 21%);
      }

      &[disabled] {
        &:hover {
          color: $button-color-tertiary-dark;
          border: $button-border-width-thick solid $button-color-tertiary-dark;
        }
      }
    }
  }

  ///////////
  // SIZES //
  ///////////
  &--small {
    min-width: 6rem;
    border-radius: 0.5rem;
    font-size: 0.8em;
    min-height: 2rem;
  }

  &--small#{&}--hollow {
    border-width: $button-border-width-thin;

    // Contexts
    .background--dark & {
      border-width: $button-border-width-thin;
    }
  }

  &--small#{&}--icon {
    [class^="icon-"] {
      height: 0.8rem;
      margin-right: 0.2rem;
      position: relative;
       top: 0.125rem;
      width: 0.8rem;
    }
  }

  &--medium {
    min-width: 8rem;
    border-radius: 0.75rem;
    min-height: 2.5rem;
  }

  &--medium#{&}--icon {
    [class^="icon-"] {
      height: 1rem;
      margin-right: 0.3rem;
      position: relative;
       top: 0.125rem;
      width: 1rem;
    }
  }

  &--large {
    min-width: 10rem;
    border-radius: 0.75rem;
    font-size: 1.2em;
    letter-spacing: 1px;
    min-height: 3rem;
  }

  &--large#{&}--icon {
    [class^="icon-"] {
      height: 1.1rem;
      margin-right: 0.35rem;
      position: relative;
       top: 0.1875rem;
      width: 1.1rem;
    }
  }

  ///////////
  // FILLS //
  ///////////
  &--solid,
  &--hollow {

    // States
    &[disabled] {
      &:active {
        transform: none !important;
      }
    }
  }
}








/////////////////////
// PAGE FORMATTING //
/////////////////////
body {
  color: $type-dark;
  padding: 3rem;
  background-color: $background-light;
}

.background {
  transition: background-color $button-transition-duration ease;

  &--light {
    background-color: $background-light;
  }

  &--dark {
    background-color: $background-dark;
  }
}

h1,
h2,
h3 {
  margin: 0;
  padding: 0;

  // Contexts
  .background--dark & {
    color: $type-light;
  }
}

h1 {
  font-size: 1.5em;
  font-weight: 600;
}

h2 {
  font-size: 1em;
  font-weight: 400;
}

h3 {
  font-size: 0.9em;
  font-weight: 400;
  letter-spacing: 1px;
  margin-top: 2.5em;
  text-transform: uppercase;
}

hr {
  border: 1px solid $type-dark;
  margin-top: 2.5rem;

  // Contexts
  .background--dark & {
    border: 1px solid $type-light;
  }
}

// SVG Icons
// This controls the default behavior of how icons look when they're declared via the `<use>` tag
[class^="icon-"],
[class*=" icon-"] {
  display: inline-block;
  width: 1em;
  height: 1em;
  stroke-width: 0;
  stroke: currentColor;
  fill: currentColor;
}

.toggle {
  background-color: $background-dark;
  border: $button-border-width-thin solid $background-light;
  color: $type-light;
  font-size: 0.8em;
  outline: none;
  position: fixed;
   right: 0.625rem;
   top: 0.625rem;
  text-align: center;
  height: 4rem;
  width: 4rem;
  border-radius: 2rem;
  z-index: 100;

  &:hover {
    background-color: darken($background-dark, 10%);
  }

  &:focus {
    box-shadow:
     0 0 0 $button-border-width-thin $background-light,
     0 0 0 ($button-border-width-thick * 1.25) $background-dark;
  }

  &:active {
    background-color: darken($background-dark, 30%);
    transform: $button-bounce;
  }

  // Contexts
  .background--dark & {
    color: $background-dark;
    background-color: $background-light;
    border: $button-border-width-thin solid $background-dark;

    &:hover {
      background-color: desaturate(darken($background-light, 10%), 100%);
    }

    &:focus {
      box-shadow:
       0 0 0 $button-border-width-thin $background-dark,
       0 0 0 ($button-border-width-thick * 1.25) $background-light;
    }

    &:active {
      background-color: desaturate(darken($background-light, 30%), 100%);
      transform: $button-bounce;
    }
  }
}
            
          
!
            
                // Applies the class `.background` to `<body>` when the page loads
$(document).ready(function() {
  $('body').addClass('background');
});

// Toggles the background modifier class
$('#background-toggle').click(function() {
  $('body').toggleClass('background--light background--dark');
});

            
          
!
999px
🕑 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.

Console