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 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.


                <canvas class="rainbow-pixel-canvas"></canvas>
Double tap to clear the canvas


                .rainbow-pixel-canvas {
  border: solid 2px gray;

  -ms-touch-action: none;
      touch-action: none;


                var pixelSize = 16;

    max: Infinity,
    maxPerElement: Infinity,
    modifiers: [
        // snap to the corners of a grid
        targets: [
          interact.snappers.grid({ x: pixelSize, y: pixelSize })
    listeners: {
      // draw colored squares on move
      move: function(event) {
        var context ="2d"),
          // calculate the angle of the drag direction
          dragAngle = 180 * Math.atan2(event.dx, event.dy) / Math.PI;

        // set color based on drag angle and speed
        context.fillStyle =
          "hsl(" +
          dragAngle +
          ", 86%, " +
          (30 + Math.min(event.speed / 1000, 1) * 50) +

        // draw squares
          event.pageX - pixelSize / 2,
          event.pageY - pixelSize / 2,
  // clear the canvas on doubletap
  .on("doubletap", function(event) {
    var context ="2d");

    context.clearRect(0, 0, context.canvas.width, context.canvas.height);

function resizeCanvases() {
  []".rainbow-pixel-canvas"), function(
  ) {
    canvas.width = document.body.clientWidth;
    canvas.height = window.innerHeight * 0.7;

// interact.js can also add DOM event listeners
interact(document).on("DOMContentLoaded", resizeCanvases);
interact(window).on("resize", resizeCanvases);