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.


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.


                <script src=""></script>
  <script src=""></script>

  <div id="myDiagramDiv" style="border: solid 3px red; width:600px; height:500px"></div>
  <p><a href=""/><a/></p>
  <label><input id="ToolEnabled" type="checkbox" checked="checked" onclick="toolEnabled()" />DragCreatingTool enabled</label>




                    function init() {
      if (window.goSamples) goSamples();  // init for these samples -- you don't need to call this
      var $ = go.GraphObject.make;  // for conciseness in defining templates

      myDiagram =
        $(go.Diagram, "myDiagramDiv",
            // Define the template for Nodes, just some text inside a colored rectangle
              $(go.Node, "Position",
                { resizable: true, resizeObjectName: 'pic' },
                new go.Binding("position", "pos", go.Point.parse).makeTwoWay(go.Point.stringify),
                // temporarily put selected nodes in Foreground layer
                new go.Binding("layerName", "isSelected", function(s) { return s ? "Foreground" : ""; }).ofObject(),
                    source: "",
                    minSize: new go.Size(60, 20),
                    desiredSize: new go.Size(60, 20),
                    name: 'pic',
                    background: 'red'
                  new go.Binding("desiredSize", "size", go.Size.parse).makeTwoWay(go.Size.stringify)
            "undoManager.isEnabled": true

          { layerName: "Grid", location: new go.Point(0, 0) },
          $(go.TextBlock, "Mouse-down and then drag in the background\nto add a Node there with the drawn size.",
            { stroke: "brown" })

      // Add an instance of the custom tool defined in DragCreatingTool.js.
      // This needs to be inserted before the standard DragSelectingTool,
      // which is normally the third Tool in the ToolManager.mouseMoveTools list.
      // Note that if you do not set the DragCreatingTool.delay, the default value will
      // require a wait after the mouse down event.  Not waiting will allow the DragSelectingTool
      // and the PanningTool to be able to run instead of the DragCreatingTool, depending on the delay.
            isEnabled: true,  // disabled by the checkbox
            delay: 0,  // always canStart(), so PanningTool never gets the chance to run
            box: $(go.Part,
                   { layerName: "Tool" },
                     { name: "SHAPE", fill: null, stroke: "cyan", strokeWidth: 2 })
            archetypeNodeData: { color: "white" }, // initial properties shared by all nodes
            insertPart: function(bounds) {  // override DragCreatingTool.insertPart
              // use a different color each time
              this.archetypeNodeData.color = go.Brush.randomColor();
              // call the base method to do normal behavior and return its result
              return, bounds);

    function toolEnabled() {
      var enable = document.getElementById("ToolEnabled").checked;
      var tool = myDiagram.toolManager.findTool("DragCreating");
      if (tool !== null) tool.isEnabled = enable;