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


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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


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.


  <h1>Ball lighter v0.1 alpha</h1>
  <p>Now with promises!  Click Run button below.</p>
  <div id="circles">
    <div id="one"></div>
    <div id="two"></div>
    <div id="three"></div>
    <div id="four"></div>

  <div id="buttons">
    <button onClick="lightBallsInParallel()">Run</button>
    <button onClick="reset()">Reset</button>



                @import url('');

html, body {
  font-family: 'Inconsolata';
  height: 100%;
body {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: slategray;
section {
  border: 1px solid #666;
  width: 400px;
  background-color: #fff;
  text-align: center;
  box-shadow: 2px 2px 5px 0px rgba(50, 50, 50, 0.31);

#circles {
  padding: 10px 0 10px 0;

#circles > div {
  transition: all 0.7s;
  border: 1px solid #666;
  width: 50px;
  height: 50px;
  display: inline-block;
  border-radius: 100%;
  margin: 0 5px 0 5px;
  box-shadow: 0px 0px 4px 0px #999;

#buttons {
  margin: 10px 0 20px 0;


                const lightBall = (id) => {
  return new Promise((resolve, reject) => {
    const el = document.getElementById(id)
    if (!el) {
      reject(`Could not find element with id ${id}`)
    } = "#FFEA85"; = "0px 0px 10px 0px #FFEA85";
    setTimeout(() => { resolve() }, 700)

const lightBallsInParallel = () => {
    .then(() => { console.log('done one') })
    .catch(err => alert(`error was ${err}`))
    .then(() => { console.log('done two') })
    .catch(err => alert(`error was ${err}`))
    .then(() => { console.log('done three') })
    .catch(err => alert(`error was ${err}`))
    .then(() => { console.log('done four') })
    .catch(err => alert(`error was ${err}`))


const reset = () => {
  ["one","two","three","four"].forEach(id => {
    document.getElementById(id).style.backgroundColor = "#fff"; 
    document.getElementById(id).style.boxShadow = "0px 0px 4px 0px #999";