Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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

              
                .app
  //- The colors
  - const colors = ['transparent', '#f22613', '#e74c3c', '#f62459', '#663399', '#9a12b3', '#bf55ec', '#19b5fe', '#1e8bc3', '#1f3a93', '#89c4f4', '#03c9a9', '#26c281', '#16a085', '#2eec71', '#f2784b', '#f89406', '#f9bf3b']
  .duotone
  .chooser.chooser--lighten
    - for (let i = 0; i < colors.length; i++)
      label.lighten(title=`Lighten w/ ${colors[i]}`, class=`${colors[i] === 'transparent' ? 'clear' : ''}`, for=`lighten--${i}`, style=`--bg: ${colors[i]}; --angle: ${(360 / colors.length) * i}`)
      input(id=`lighten--${i}`, type='radio', value=`${colors[i]}`, name='lighten', style=`--angle: ${(360 / colors.length) * i}`)
  .chooser.chooser--darken
    - for (let i = 0; i < colors.length; i++)
      label.darken(title=`Darken w/ ${colors[i]}`, class=`${colors[i] === 'transparent' ? 'clear' : ''}`, for=`darken--${i}`, style=`--bg: ${colors[i]}; --angle: ${(360 / colors.length) * i}`)
      input(id=`darken--${i}`, type='radio', value=`${colors[i]}`, name='darken', style=`--angle: ${(360 / colors.length) * i}`)
  svg.indicator(preserveAspectRatio='xMinYMin', viewBox="0 0 24 24")
    path(d="M7,10L12,15L17,10H7Z")
              
            
!

CSS

              
                *
  box-sizing border-box

body
  background-color #111
  min-height 100vh
  overflow hidden
  overflow-y scroll
  display flex
  align-items center
  justify-content center

$duration = .25s
$border = 4px

.app
  background linear-gradient(45deg, #aaa, #111)
  width 100vw
  height 100vh
  min-height 550px
  position relative
.duotone
  background url('https://source.unsplash.com/220x220?bear,cat'), linear-gradient(45deg, #111, #aaa)
  background-size cover
  border-radius 100%
  height 220px
  left 50%
  overflow hidden
  position absolute
  top 50%
  transform translate(-50%, -50%)
  width 220px

  &:after
  &:before
    bottom 0
    content ''
    left 0
    position absolute
    right 0
    top 0
    transition background $duration $duration

  &:after
    background var(--lighten)
    mix-blend-mode lighten

  &:before
    background var(--darken)
    mix-blend-mode darken

.indicator
  height 40px
  left 50%
  position absolute
  top 50%
  transform translate(-50%, -260px)
  width 40px
  path
    fill #fff

input
  display none

.chooser
  position absolute
  top 50%
  left 50%
  transform rotate(calc(((var(--selectedRotation, 0) * -1) - 90) * 1deg))
  transition transform $duration ease

label
  background var(--bg)
  border $border solid #fafafa
  border-radius 100%
  cursor pointer
  height 44px
  left 50%
  position absolute
  top 50%
  transform translate(-50%, -50%) rotate(calc(var(--angle) * 1deg)) translateX(150px)
  width 44px

  &.darken
    transform translate(-50%, -50%) rotate(calc(var(--angle) * 1deg)) translateX(200px)

.clear
  border-color red
  border-width $border
  overflow hidden

  &:after
    background #f22613
    content ''
    height $border
    left 50%
    position absolute
    top 50%
    transform translate(-50%, -50%) rotate(45deg)
    width 100%


              
            
!

JS

              
                const duotone = document.querySelector('.duotone')
const choosers = {
  darken: document.querySelector('.chooser--darken'),
  lighten: document.querySelector('.chooser--lighten'),
}
const updateTone = (e) => {
  const {
    name,
    value,
  } = e.target
  duotone.style.setProperty(`--${name}`, value)
  choosers[name].style.setProperty('--selectedRotation', e.target.style.getPropertyValue('--angle'))
}
document.body.addEventListener('input', updateTone)
document.body.addEventListener('change', updateTone)
              
            
!
999px

Console