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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

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



Go PRO Window blinds lowered to protect code. Code Editor with window blinds (raised) and a light blub turned on.

Keep it secret; keep it safe.

Private Pens are hidden everywhere on CodePen, except to you. You can still share them and other people can see them, they just can't find them through searching or browsing.

Upgrade to PRO


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.


Make Template?

Templates are Pens that can be used to start other Pens quickly from the create menu. The new Pen will copy all the code and settings from the template and make a new Pen (that is not a fork). You can view all of your templates, or learn more in the documentation.

Template URL

Any Pen can act as a template (even if you don't flip the toggle above) with a special URL you can use yourself or share with others. Here's this Pen's template URL:


Screenshot or Custom Thumbnail

Screenshots of Pens are shown in mobile browsers, RSS feeds, to users who chose images instead of iframes, and in social media sharing.

This Pen is using the default Screenshot, generated by CodePen. Upgrade to PRO to upload your own thumbnail that will be displayed on previews of this pen throughout the site and when sharing to social media.

Upgrade to PRO


                <script src=""></script>

  <div id="myDiagram" style="border: solid 3px red; width:300px; height:300px;"></div>
  <div id="myTreeDiagram" style="border: solid 3px red; width:300px; height:300px;"></div>




                  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, "myDiagram",
                    initialContentAlignment: go.Spot.Center,  // center the content
                    "undoManager.isEnabled": true,  
                    layout: $(go.TreeLayout, { layerSpacing: 35, alignment: go.TreeLayout.AlignmentStart })
    myDiagram.nodeTemplate =
      $(go.Node, "Auto",  // the Shape will go around the TextBlock
        $(go.Shape, "RoundedRectangle",
      				click: function (e, object) {
          // Shape.fill is bound to
          new go.Binding("fill", "color")),
          { margin: 3 },  // some room around the text
          // TextBlock.text is bound to
          new go.Binding("text", "key"))
    myDiagram.groupTemplate =
    $(go.Group, "Auto",
      	layout: $(go.LayeredDigraphLayout,
                  { direction: 0, columnSpacing: 10 })
      $(go.Shape, "RoundedRectangle", // surrounds everything
        { parameter1: 10, fill: "rgba(128,128,128,0.33)" }),
      $(go.Panel, "Vertical",  // position header above the subgraph
        { defaultAlignment: go.Spot.Left },
        $(go.Panel, "Horizontal",  // the header
          { defaultAlignment: go.Spot.Top },
          $("SubGraphExpanderButton"),  // this Panel acts as a Button
          $(go.TextBlock,     // group title near top, next to button
            { font: "Bold 12pt Sans-Serif" },
            new go.Binding("text", "key"))
        $(go.Placeholder,     // represents area for all member parts
          { padding: new go.Margin(0, 10), background: "white" })
    // but use the default Link template, by not setting Diagram.linkTemplate

    // create the model data that will be represented by Nodes and Links
    myDiagram.model = new go.GraphLinksModel(
      { key: "Alpha", color: "lightblue", isGroup: true },
      { key: "Beta", color: "orange", group: "Alpha"},
      { key: "Gamma", color: "lightgreen" },
      { key: "Delta", color: "pink" }
      { from: "Gamma", to: "Delta" },
      { from: "Delta", to: "Alpha" }
       myTreeDiagram = $(go.Diagram, "myTreeDiagram", {initialContentAlignment: go.Spot.Center, layout:
                    alignment: go.TreeLayout.AlignmentStart,
                    angle: 0,
                    compaction: go.TreeLayout.CompactionNone,
                    layerSpacing: 16,
                    layerSpacingParentOverlap: 1,
                    nodeIndent: 2,
                    nodeIndentPastParent: 0.88,
                    nodeSpacing: 0,
                    setsPortSpot: false,
                    setsChildPortSpot: false
    myTreeDiagram.nodeTemplate =
          // no Adornment: instead change panel background color by binding to Node.isSelected
          { selectionAdorned: false },
              width: 14,
              "ButtonBorder.fill": "whitesmoke",
              "ButtonBorder.stroke": null,
              "_buttonFillOver": "rgba(0,128,255,0.25)",
              "_buttonStrokeOver": null
          $(go.Panel, "Horizontal",
            { position: new go.Point(16, 0) },
            new go.Binding("background", "isSelected", function (s) { return (s ? "lightblue" : "white"); }).ofObject(),
                width: 14, height: 14,
                margin: new go.Margin(0, 4, 0, 0),
                imageStretch: go.GraphObject.Uniform,
              new go.Binding("text", "key", function (s) { return s; }))
          )  // end Horizontal Panel
        );  // end Node
    myTreeDiagram.linkTemplate = $(go.Link);
 myTreeDiagram.model = myDiagram.model;
    //Using this property incorrectly?
    myTreeDiagram.model.nodeParentKeyProperty = "group";

What did the colon say to the semicolon? Stop winking at me.