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

              
                <div id="app"></div>
              
            
!

CSS

              
                body
  text-align center
  
h1
  color #FF8446
  font-size 3em
  margin .3em

button
  border solid 1px #FF8446
  background lighten(#FF8446, 10%)
  padding .5em 1em
  color white
  font-weight bold
   
  & + button
    margin-left .3em
   
body > div

  & > div
    margin 0 1em

pre
  text-align left
 
.counter
  transition opacity 2s linear
  opacity 1

  &[leave="leave"]
    opacity 0

              
            
!

JS

              
                // @jsx x
const { x, atto, Context } = xatto

const down = context => ({ count: context.count - 1 })
const up = context => ({ count: context.count + 1 })

const Counter = (props, children, context) => (
  <div>
    <h1>{context.count}</h1>
    <button onclick={down}>-</button>
    <button onclick={up}>+</button>
  </div>
)

let idx = 2

const add = context => ({
  counters: { ...context.counters, ...(Object.fromEntries([[idx++, {count: 0}]])) }
})

const cut = context => {
  const entry = Object.entries(context.counters).slice(-1)[0]
  if (entry == null) {
    return
  }
  delete context.counters[entry[0]]
  return {
    counters: { ...context.counters }
  }
}

const Main = (props, children, context) => (
  <div>
    <button onclick={add}>add</button>
    <button onclick={cut}>cut</button>

    {Object.entries(context.counters)
      .map(([i, v]) => (<Context slice={'counters.' + i}><Counter /></Context>))}

    <pre>{JSON.stringify(context, null, '  ')}</pre>
  </div>
)

atto(Main, document.getElementById("app"))({
  counters: {
    0: { count: 0 },
    1: { count: 10 }
  }
})

              
            
!
999px

Console