Amazing native Modal with just HTML: meet element

amazing-native-modal-with-just-html:-meet--element

The Web as a platform is constantly evolving. And I love it!

Developers no longer need to create complex logics to have a Popup / Modal component in your Web applications.

The HTML dialog element and it’s associated events allow you to create fast and accessible native custom dialog boxes.

Top features

This features are native of the Dialog element and the browser implementation:

  • Events (open, close, cancel)
  • Autofocus on opened dialog (just press “tab” key to navigate inside)
  • Closes when the user press “esc” key
  • Automatic scroll
  • Keep stacking context (dialog over dialog)
  • Includes a ::backdrop pseudo-element for behind the element

Browser compatibility

Dialog element has 93% of browsers’ compatibility, in other words, it is considered full support!

Visit the references Can I Use and MDN Web Docs for more details.

Demo code

I created a simple Demo code that show Dialog element in action and print as the result of user interaction the names of events handled.

Feel free to explore the code 👇🏻

https://codepen.io/lucasm/pen/YzRBzVQ

Explanation

1) In HTML, you need to create a

element and attribute an ID to manipulate it

2) Also create an

Total
0
Shares
Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post
building-a-restful-api-with-node.js:-testing-api

Building a RESTful API with Node.js: Testing API

Next Post
the-advantages-of-using-agile-methodology-in-mobile-application-development

The Advantages of Using Agile Methodology in Mobile Application Development

Related Posts