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

              
                <div id="gjs" style="height:0px; overflow:hidden;">
  <div class="panel">
    <h1 class="welcome">Welcome to</h1>
    <div class="big-title">
      <svg class="logo" viewBox="0 0 100 100">
        <path d="M40 5l-12.9 7.4 -12.9 7.4c-1.4 0.8-2.7 2.3-3.7 3.9 -0.9 1.6-1.5 3.5-1.5 5.1v14.9 14.9c0 1.7 0.6 3.5 1.5 5.1 0.9 1.6 2.2 3.1 3.7 3.9l12.9 7.4 12.9 7.4c1.4 0.8 3.3 1.2 5.2 1.2 1.9 0 3.8-0.4 5.2-1.2l12.9-7.4 12.9-7.4c1.4-0.8 2.7-2.2 3.7-3.9 0.9-1.6 1.5-3.5 1.5-5.1v-14.9 -12.7c0-4.6-3.8-6-6.8-4.2l-28 16.2" />
      </svg>
      <span>GrapesJS</span>
    </div>
    <div class="description">
      This is a demo content from index.html. For the development, you shouldn't edit this file, instead you can
      copy and rename it to _index.html, on next server start the new file will be served, and it will be ignored by
      git.
    </div>
  </div>
  <style>
    .panel {
      width: 90%;
      max-width: 700px;
      border-radius: 3px;
      padding: 30px 20px;
      margin: 150px auto 0px;
      background-color: #d983a6;
      box-shadow: 0px 3px 10px 0px rgba(0, 0, 0, 0.25);
      color: rgba(255, 255, 255, 0.75);
      font: caption;
      font-weight: 100;
    }

    .welcome {
      text-align: center;
      font-weight: 100;
      margin: 0px;
    }

    .logo {
      width: 70px;
      height: 70px;
      vertical-align: middle;
    }

    .logo path {
      pointer-events: none;
      fill: none;
      stroke-linecap: round;
      stroke-width: 7;
      stroke: #fff
    }

    .big-title {
      text-align: center;
      font-size: 3.5rem;
      margin: 15px 0;
    }

    .description {
      text-align: justify;
      font-size: 1rem;
      line-height: 1.5rem;
    }
  </style>
</div>
              
            
!

CSS

              
                body,
html {
  height: 100%;
  margin: 0;
}

              
            
!

JS

              
                window.editor = grapesjs.init({
  height: "100%",
  container: "#gjs",
  showOffsets: true,
  fromElement: true,
  noticeOnUnload: false,
  storageManager: false,
  plugins: ["grapesjs-script-editor", "grapesjs-rulers"],
  pluginsOpts: {
    "grapesjs-script-editor": {
      /* Test here your options  */
    }
  }
});

const pn = editor.Panels;
const panelViews = pn.addPanel({
  id: "options"
});
panelViews.get("buttons").add([
  {
    active: 1,
    attributes: {
      title: "Toggle Rulers"
    },
    label: `<svg width="18" viewBox="0 0 16 16"><path d="M0 8a.5.5 0 0 1 .5-.5h15a.5.5 0 0 1 0 1H.5A.5.5 0 0 1 0 8z"/><path d="M4 3h8a1 1 0 0 1 1 1v2.5h1V4a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v2.5h1V4a1 1 0 0 1 1-1zM3 9.5H2V12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V9.5h-1V12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V9.5z"/></svg>`,
    command: "ruler-visibility",
    id: "ruler-visibility"
  }
]);

editor.runCommand("ruler-visibility");

              
            
!
999px

Console