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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


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


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.


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.


                - const colors = [{name: 'Red', hex: '#e74c3c'}, {name: 'Orange', hex: '#f9690e'}, {name: 'Yellow', hex: '#f9bf3b'}, {name: 'Green', hex: '#2ecc71'}, {name: 'Blue', hex: '#4b77be'}, {name: 'Indigo', hex: '#180c37'}, {name: 'Violet', hex: '#640d6b'}]
h1.counter 0
label(for='propagationCheck') create dead zone with stopPropagation
input(type='checkbox', id='propagationCheck')
    h1.menu__title Choose background color
      - for (let color of colors)
        li.menu__color(style=`--color: ${color.hex}`)=


                @import url('')

  box-sizing border-box

  --bg-color #e74c3c
  background-color var(--bg-color)
  font-family 'Lato', sans-serif
  margin 0
  transition background .75s ease 0s
  text-align center

  color #fff
  text-align center
  font-size 5rem

  --translate -100%
  background-color #fafafa
  width 200px
  position fixed
  top 0
  left 0
  height 100vh
  transform translateX(var(--translate))
  transition transform 0.25s

    cursor pointer
    position absolute
    height 35px
    left 100%
    padding 4px
    top 0
    width 45px

      width 100%
      height 5px
      margin 6px auto
      background-color #fff
      transition transform .25s, opacity .25s

    --translate 0

      transform rotate(-45deg) translate(-9px, 6px)
      opacity 0
      transform rotate(45deg) translate(-8px, -8px)

    padding 10px
    width 200px

    font-size 1rem

    list-style none
    padding 0

    background linear-gradient(160deg, white, white 30%, var(--color))
    cursor pointer
    padding 4px



                const root = document.documentElement
const OPEN_CLASS = 'menu--open'
const menu = document.querySelector('.menu')
const menuColors = menu.querySelector('.menu__colors')
const menuBtn = menu.querySelector('.menu__button')
const counter = document.querySelector('.counter')
const propCheck = document.querySelector('#propagationCheck')

document.addEventListener('click', () => counter.innerText = parseInt(counter.innerText, 10) + 1)

const changeBg = (e) => {'--bg-color','--color'))
menuColors.addEventListener('click', changeBg)

const addOffClick = (e, cb) => {
  const offClick = (evt) => {
    if (e !== evt) {
      document.removeEventListener('click', offClick)
  document.addEventListener('click', offClick)

const handleClick = (e) => {
  const toggleMenu = () => menu.classList.toggle(OPEN_CLASS)
  if (propCheck.checked) e.stopPropagation()
  if (!menu.classList.contains(OPEN_CLASS)) {
    addOffClick(e, toggleMenu)

menuBtn.addEventListener('click', handleClick)