Build Status

<dialog-el>

Intro

This repo is a Custom Element for creating accessible dialogs/modals It is heavily inspired by Polymer's paper-dialog and the A11y Dialog fork from Edenspiekermann.

Demo

Click the following buttons to see different types of modals

Auto Positioning Demo

NOTE: the auto positioning will only work reliably on a dialog with fixed height & width. It will also function differently based on the existance of the arrow-direction attribute.

Standard Positioning

The following dialog will always fly out to the side of the screen with the most space

Arrow Positioning

The following dialog will always such that the arrow is pointing at the center of the passed element (in this case the button)

Auto Position Dialog!

This dialog will be automatically positioned relative to the button.

NOTE: This will only work on a dialog with fixed width

Demo Dialog!

This is a simple dialog! Look at me go!

Demo Modal!

This is a simple modal! I stole all the focus yeah!

Demo Dialog!

This is a dialog with another dialog inside! Click below to open the nested dialog

Demo Dialog!

This is a nested dialog! Here I am!

Demo Dialog!

This is a modal with another dialog inside! Click below to open the nested dialog

Demo Dialog!

This is a nested dialog! Here I am!

Fancy Header

Arrow Direction Dialog!

This dialog should have an arrow pointing left. Note that positioning is up to the containing element.

Auto Position Dialog!

This dialog will be automatically positioned relative to the button.

NOTE: This will only work on a dialog with fixed width

Dependencies

There are no non-native dependencies in this Web Component. If your browser supports the following two things you are good. If not you will need to make sure you load the Polyfills first

Utilization

Because this is a Web Component you can instantiate it using one of two methods:

HTML

    
      <dialog-el>
        <!-- Your dialog/modal content -->
      </dialog-el>
    
  

JS

    
      var dialogEl = document.createElement('dialog-el');
      document.body.appendChild(dialogEl);
    
  

Methods

Properties

Events

CSS Custom Properties

Use these to override default styles

Property Name Description Default Value
--dialog-el-padding Used as the padding for the dialog 15px
--dialog-el-background Used for the background property of the dialog #FFFFFF

These defaults effectively wrap your provided local DOM in a 15px white border. Override them to change the appearance.