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="demo">
  <div class="tooltip-container">
    <label class="checkbox-label" for="showTooltip">Show tooltip</label>
    <input type="checkbox" id="showTooltip" name="showTooltip" value="Show">
  </div>
  <div class="tooltip-container">
    <div class="tooltip false-tooltip">Content returns false<br>if "Show tooltip" is unchecked</div>
  </div>
  <div class="tooltip-container">
    <div class="tooltip undefined-tooltip" data-my-tooltip="My Tooltip">Content returns undefined</div>
  </div>
  <div class="tooltip-container">
    <div class="tooltip function-tooltip">Content returns a  value</div>
  </div>
  <div class="tooltip-container">
    <div class="tooltip string-tooltip">Content is a string</div>
  </div>
</div>

<a target="_blank" href="https://www.jointjs.com">
  <img id="logo" src="https://assets.codepen.io/7589991/jointjs-logo.svg" width="200" height="50"></img>
</a>
              
            
!

CSS

              
                body {
  background: #f7f7f7;
}

#demo {
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  width: 380px;
  height: 400px;
  text-align: center;
  -webkit-box-shadow: 0 0 14px 0 rgba(0, 0, 0, 0.25);
  -moz-box-shadow: 0 0 14px 0 rgba(0, 0, 0, 0.25);
  box-shadow: 0 0 14px 0 rgba(0, 0, 0, 0.25);
  border-radius: 10px;
  margin-bottom: 30px;
  background: white;
}

.checkbox-label {
  padding: 0 8px;
  font-size: 16px;
  font-family: "Courier New", monospace;
}

.tooltip {
    padding: 5px;
    border: 2px solid #ed2637;
    border-radius: 10px;
    cursor: pointer;
    font-family: "Courier New", monospace;
}

.tooltip-container {
    display: flex;
    flex-direction: row;
    margin: auto;
}

.checkbox-label {
    display: flex;
    align-items: center;
}

input {
    margin-right: 10px;
}

#logo {
  position: absolute;
  bottom: 20px;
  right: 0;
}
              
            
!

JS

              
                // `content` function returns `false` (new behavior)
const falseTooltip = new joint.ui.Tooltip({
    target: '.false-tooltip',
    position: 'top',
    padding: 15,
    content: () => {
        return document.querySelector('#showTooltip').checked ? 'Checkbox is checked': false;
    }
});

// ----------
// `content` function returns `undefined` (new behavior)
const undefinedTooltip = new joint.ui.Tooltip({
    target: '.undefined-tooltip',
    position: 'top',
    padding: 15,
    dataAttributePrefix: 'my-tooltip',
    content: () => { return; }
});

// ----------
// `content` function returns a value (original behavior)
const contentFunctionTooltip = new joint.ui.Tooltip({
    target: '.function-tooltip',
    position: 'top',
    padding: 15,
    content: (element) => `Content returns a value`
});

// ----------
// `content` is a string (original behavior)
const contentStringTooltip = new joint.ui.Tooltip({
    target: '.string-tooltip',
    position: 'top',
    padding: 15,
    content: 'Static text'
});
              
            
!
999px

Console