Pen Settings

HTML

CSS

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

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

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.

HTML

              
                <!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Modal demo</title>
  <link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet">
  
  <!-- Teleport plugin -->
  <script defer src="https://unpkg.com/alpine-teleport@1.x.x/dist/cdn.min.js"></script>

  <!-- Alpine Core -->
  <script defer src="https://unpkg.com/alpinejs@3.x.x/dist/cdn.min.js"></script>

  <script src="./app.js"></script>
</head>
<body class="relative flex flex-col items-center justify-center overflow-hidden bg-gradient-to-r from-blue-400 to-indigo-500 h-screen">

  <div x-data="dialog">
    <div class="fixed inset-0 flex items-center justify-center">
      <button
        type="button"
        @click.prevent="open"
        class="px-4 py-2 text-sm font-medium text-white bg-black rounded-md bg-opacity-20 hover:bg-opacity-30 focus:outline-none focus:ring-2 focus:ring-white focus:ring-opacity-75">
          Open dialog
      </button>
    </div>

    <template x-if="opened">
      <template x-teleport="#modal-container">
        <div class="fixed inset-0 z-10 overflow-y-auto">
          <div class="min-h-screen px-4 text-center">
            <!-- Overlay -->
            <div class="bg-gray-900 bg-opacity-30 fixed inset-0" aria-hidden="true"></div>

            <span class="inline-block h-screen align-middle" aria-hidden="true">
              &#8203;
            </span>

            <div
              class="inline-block w-full max-w-md p-6 my-8 overflow-hidden text-left align-middle transition-all transform bg-white shadow-xl rounded-2xl"
            >
              <h2> Payment successful </h2>
              <div class="mt-2">
                <p class="text-sm text-gray-500">
                  Your payment has been successfully submitted. We’ve sent
                  your an email with all of the details of your order.
                </p>
              </div>
              <div class="mt-4">
                <button
                  x-ref="focusItem"
                  type="button"
                  class="inline-flex justify-center px-4 py-2 text-sm font-medium text-blue-900 bg-blue-100 border border-transparent rounded-md hover:bg-blue-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"
                  @click.prevent="close"
                >
                  Got it, thanks!
                </button>
              </div>
            </div>
          </div>
        </div>
      </template>
    </template>
  </div>

  <div id="modal-container"></div>
</body>
</html>
              
            
!

CSS

              
                
              
            
!

JS

              
                document.addEventListener('alpine:init', () => {
  Alpine.data('dialog', function () {
    return {
      opened: false,
      lastFocusedItem: null,
      open () {
        this.opened = true
        this.$nextTick(() => {
          this.lastFocusedItem = document.activeElement
          if (this.$refs.focusItem) {
            this.$nextTick(() => {
              this.$refs.focusItem.focus()
            })
          }
        })
      },
      close () {
        this.opened = false
        if (this.lastFocusedItem) {
          this.lastFocusedItem.focus()
        }
      }
    }
  })
})
              
            
!
999px

Console