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

              
                template#myc-template
  div.alert 
    | X is {{ x }}, and Y is {{ y }}, so 
    | z being <code>x &times; y</code> is {{ z }}
    br
    | The message: 
    span(data-bind='upperCase: message')

my-component(params='x: 1234, y: 955, message: "Expect big z big"')

my-component(params='x: 9, y: 3, message: "Expect z of 27"')

// The `upperCase` binding won't work outside <my-component>.
              
            
!

CSS

              
                
              
            
!

JS

              
                class MyComponent extends ko.Component {
  /**
   * The ko.Component extends the LifeCycle
   */
  constructor ({x, y, message}) {
    super()
    Object.assign(this, {x, y, message})
    this.z = this.computed('computeZ')
  }
  
  /**
   * Return the custom element name for this component
   */
  static get elementName () {
    return 'my-component' // In DOM as <my-component>
  }
  
  /**
   * Use `element` to return:
   *  1. a DOM node ID or a 
   *  2. DOM node.
   */
  static get element () {
    return 'myc-template'
  }
  
  /**
   * Overload `static get template` to minic the Knockout
   * `template` parameter to view registration.
   */
  // static get template () { return '<div>...</div>' }
  
  /**
   * Return true when a component should be loaded
   * synchronously; false otherwise.
   */
  static get sync () {
    return true
  }
  
  /**
   * Return a binding handlers local to this
   * (or falsy if not found).
   */
  getBindingHandler (bindingKey) {
    return {
      upperCase (element, valueAccessor) {
        return element.innerText = valueAccessor().toUpperCase()
      }
    }[bindingKey]
  }
  
  computeZ() {
    return this.x * this.y
  }
}

MyComponent.register(/* custom-name */)

ko.applyBindings({})
              
            
!
999px

Console