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

              
                <main id=app></main>
              
            
!

CSS

              
                @import "https://unpkg.com/water.css@2/out/water.min.css";

body {
  font-size: 1.5em;
}


              
            
!

JS

              
                import { h, text, app } from "https://unpkg.com/hyperapp"

/// Utils

const pad = (n) => (n < 10 ? "0" + n : n)

const humanizeTime = (t) => {
  const hours = (t / 3600) >> 0
  const minutes = ((t - hours * 3600) / 60) >> 0
  const seconds = (t - hours * 3600 - minutes * 60) >> 0
  return `${pad(minutes)}:${pad(seconds)}`
}

/// Time Fx

const interval = (dispatch, props) => {
  const id = setInterval(() => dispatch(props.action, Date.now()), props.delay)
  return () => clearInterval(id)
}

const every = (delay, action) => [interval, { delay, action }]

/// Html

const main = (...children) => h("main", {}, children)
const title = (title) => h("h1", {}, text(title))
const button = (onclick, children) => h("button", { onclick }, text(children))

/// Main

const resetState = { count: 10 }
const countdown = (state) => ({ count: state.count - 1 })
const toggle = (state) => ({ paused: !state.paused })

const Tick = (state) =>
  state.count === 0
    ? { ...state, ...resetState, ...toggle(state) }
    : !state.paused
    ? { ...state, ...countdown(state) }
    : state

const Reset = (state) => ({ ...state, ...resetState })

const Toggle = (state) => ({ ...state, ...toggle(state) })

app({
  init: {
    ...resetState,
    paused: true,
  },
  view: (state) =>
    main(
      title(`⏱ ${humanizeTime(state.count)}`),
      button(Toggle, state.paused ? "▶️ Start" : "Pause ✋"),
      button(Reset, "Reset")
    ),
  subscriptions: () => [every(1000, Tick)],
  node: document.getElementById("app"),
})

              
            
!
999px

Console