Pen Settings



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


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.


                <div id="root"></div>


                #red {
  color: red;

.blue {
  color: blue;


                const h = (tag, props={}, children=[]) => {
  // create the element
  const element = document.createElement(tag)
  // loop through the props
  for(const [key, value] of Object.entries(props)) {
    // if the prop starts with "on" then add it is an event listener
    // otherwise just set the attribute
    if(key.startsWith("on")) {
      const event = key.substring(2).toLowerCase()
      element.addEventListener(event, value)
    } else {
      element.setAttribute(key, value)
  // loop through the children
  for(const child of children) {
    // if the child is a string then add it as a text node
    // otherwise just add it as an element
    if(typeof child == "string") {
      const text = document.createTextNode(child)
    } else {
  // return the element
  return element

const elements = new Proxy({}, {
  get: (_, tag) => 
    (props, ...children) => 
      h(tag, props, children)

const { button, div, h1, p } = elements

const buttonStyles = `
  outline: none;
  border: none;
  font-family: sans-serif;
  color: #fff;
  background: dodgerblue;
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;

  h1({ id: "red" }, "Hello World"),
  p({ class: "blue" }, "This is a paragraph"),
  button({ onclick: () => alert("bruh"), style: buttonStyles }, "click me")