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

              
                This is an example of defining a custom component in Zwibbler. 
<zwibbler>
  <ZoomButtons mycaption="'Hello world'"></ZoomButtons>
  <ZoomButtons mycaption="'This is another caption'"></ZoomButtons>
  <div z-canvas style="height:500px"></div>
</zwibbler>

<script src="https://zwibbler.com/zwibbler-demo.js"></script>
              
            
!

CSS

              
                
              
            
!

JS

              
                // We will define a reusuable component called ZoomButtons.
// If you write <ZoomButtons></ZoomButtons> anywhere in the main <zwibbler> element, 
// it will be replaced with the HTML defined where and the controller method will be
// run on it.
Zwibbler.component("ZoomButtons", {
    // This CSS will be injected into the document when the component is used.
    // It is good practice to limit the effects of the style to your component
    // using selectors, since this is not automatically done for you.
    style: `
        .ZoomButtons {
            display: flex;
            flex-flow: row;
            align-items: center;
        }
        
        .ZoomButtons span {
           border-radius: 3px;
           margin: 5px;
           background: pink;
           padding: 3px;
        }
    `,

    template: `
    <div class="ZoomButtons">
      <button z-on:click="ctx.zoomIn()">Zoom in</button>
      <button z-on:click="ctx.zoomOut()">Zoom out</button>
      <span z-text="getDisplayedZoom()"></span>
      <span z-text="mycaption"></span>
    </div>
    `,
  
     // Here is a list of attributes that Zwibbler should take from the element.
     // Everytime something changes in document, zwibbler will set
     // scope.mycaption to the value of this parameter. That is why they have to be
     // double-quoted when you use them. They must be a valid javascript expression that
     // can be evaluated.
     properties: ["mycaption"],

    controller(scope) {
      // scope.$parent refers to the parent scope that this one is defined in. We will
      // reach into it and get the main zwibbler context.
      let ctx = scope.ctx = scope.$parent.ctx;
      
      // We define this method on the scope to get the zoom level to display.
      scope.getDisplayedZoom = () =>{
        return `${Math.round(ctx.getCanvasScale()*100)}%`;
      }
    }
})
              
            
!
999px

Console