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.


                <button>Hover for a new image</button>


                html, body {
  min-height: 400px;

button {
  background: #ddd;
  border: none;
  font-size: 20px;
  padding: 10px 20px;

.tippy-tooltip.ajax-theme {
  position: absolute;
  width: 200px;
  padding: 0;
  overflow: hidden;

.tippy-tooltip.ajax-theme img {
  display: block;
  max-width: 100%;

We need to "pin" the tooltip absolutely to the bottom or top of the popper element depending on the placement.
.tippy-tooltip.ajax-theme[x-placement^='top'] {
  top: auto !important;
  bottom: 0;

.tippy-tooltip.ajax-theme[x-placement^='bottom'] {
  bottom: auto !important;
  top: 0;


                const INITIAL_CONTENT = '<div style="margin:5px 0;">Loading...</div>'

function applyStyles(popper, tooltip) {
  // Because the tooltip has `position: absolute`,
  // it no longer affects the parent popper's layout.
  // We need to explicitly give it a width. = '200px'

  // Setup transition styles on the tooltip itself = '0.2s' = 'visibility, opacity, height'

function animateHeight(instance, instanceContent) {
  const { popper } = instance
  const { tooltip, content } = instance.popperChildren
  function onTransitionEnd(event) {
    if ( === event.currentTarget) { = '1'
  // Wait until the height transition has finished before
  // fading the content in. Since we have `overflow: hidden`
  // on the tooltip this isn't actually needed, but if you
  // have an arrow element it will be.
  if (!instance._transitionEndListener) {
    instance._transitionEndListener = onTransitionEnd

  tooltip.addEventListener('transitionend', onTransitionEnd)
  // Store the base height of the tooltip when it has the
  // initial Loading... content.
  if (!instance._baseHeight) {
    instance._baseHeight = tooltip.clientHeight

  // Here is where we find out the height of the tooltip
  // when it has the content. We could technically hardcode
  // 200px as the value, but it's useful to know how to do
  // this with dynamic content. = '0'
  // Temporarily set the image as the tooltip's content
  // so we can find out the final height of the tooltip.
  const height = tooltip.clientHeight
  // Apply the height to the parent popper element. = height + 'px'
  // Reset the tooltip's height to the base height. = instance._baseHeight + 'px'
  // Cause reflow so we can start the height transition.
  void tooltip.offsetHeight
  // Start the transition. = height + 'px'
  // Remove the Loading... content and wait until the
  // transition finishes.

tippy('button', {
  animation: 'fade',
  animateFill: false,
  theme: 'ajax',
  async onShow(instance) {
    if (instance.state.isFetching === true || instance.state.canFetch === false) {

    instance.state.isFetching = true
    instance.state.canFetch = false
    applyStyles(instance.popper, instance.popperChildren.tooltip)
    try {
      const response = await fetch('')
      const blob = await response.blob()
      const url = URL.createObjectURL(blob)
      // If the tooltip hid before finishing the request, stop further action
      if (!instance.state.isVisible) {
      const img = new Image()
      img.width = 200
      img.height = 200
      img.src = url
      animateHeight(instance, img)
    } catch (error) {
      instance.setContent('An error occurred')
    } finally {
      instance.state.isFetching = false
  onHidden(instance) {
    const { tooltip } = instance.popperChildren
    instance.state.canFetch = true
    instance.setContent(INITIAL_CONTENT) = null
    tooltip.removeEventListener('transitionend', instance._transitionEndListener)
    instance._transitionEndListener = null