cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.


  button.button.js-toggle Toggle content

              $color--white = #FFFFFF
$color--black = #000000
$color--off-white = #E6E6E6
$color--grey = #d8d8d8
$color--image = #d7692c
$color--primary = #2AA1C0
$color--secondary = #0E647D

  box-sizing border-box

html, body
  height 100%

  display flex
  flex-direction column
  flex-wrap wrap
  justify-content center
  align-items center
  width 100%
  height 100%
  background $color--off-white
  font-family 'Source Sans Pro', sans-serif

  width 100%
  max-width 300px
  min-height 400px
  margin 10px
  background $color--white
  border-bottom 1px solid $color--grey
  box-shadow 0 1px 4px 0 rgba(0, 0, 0, 0.1)

  position relative
  width 100%
  height 0
  padding-bottom 60%
  background $color--image
  overflow hidden

    content ''
    position absolute
    width 100%
    height 100%
    background linear-gradient(90deg, rgba(0, 0, 0, 0), rgba($color--white, 15%), rgba(0, 0, 0, 0))
    transform translateX(-100%)
    animation loading 1.5s infinite

    position relative
    max-width 100%
    z-index 1

@keyframes loading
    transform translateX(100%)
  padding 20px
  margin-top 0
  margin-bottom 10px
  font-family 'Alegreya Sans', sans-serif
  font-weight 400

    width 100%
    height 35px
    background $color--grey
    margin-bottom 20px

  margin 0
  font-size 20px
  line-height 1.35
    width 90%
    height 20px
    background $color--grey
  margin 10px
  padding 15px 20px
  background $color--primary
  border 0
  color $color--white
    background $color--secondary
              const toggle = document.querySelector('.js-toggle')
    , image = document.querySelector('.js-image')
    , heading = document.querySelector('.js-heading')
    , paragraph = document.querySelector('.js-paragraph')

let content = false

toggle.addEventListener('click', function() {
  if(content === false) {
    content = true
    image.src = 'http://unsplash.it/400/400?image=564'
    heading.innerHTML = 'Some heading'
    paragraph.innerHTML = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Culpa rerum porro aut laboriosam animi.'
  } else {
    content = false
    image.src = ''
    heading.innerHTML = ''
    paragraph.innerHTML = ''
🕑 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.
Loading ..................