You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the native HTML dialog component means we can create modals without using a lot of custom markup (like a bunch of div elements). It comes standard with a backdrop customizable via CSS and accessibility features like focus and closing on ESC.
Additional context
This is how Spectrum creates modals:
<divclass="spectrum-Modal-wrapper spectrum-CSSExample-dialog"><divclass="spectrum-Modal is-open"><divclass="spectrum-Dialog spectrum-Dialog--small" role="dialog" tabindex="-1" aria-modal="true"><divclass="spectrum-Dialog-grid"><h1class="spectrum-Dialog-heading">Disclaimer</h1><hrclass="spectrum-Divider spectrum-Divider--sizeM spectrum-Divider--horizontal spectrum-Dialog-divider"><sectionclass="spectrum-Dialog-content">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Auctor augue mauris augue neque gravida. Libero volutpat sed ornare arcu. Quisque egestas diam in arcu cursus euismod quis viverra. Posuere ac ut consequat semper viverra nam libero justo laoreet. Enim ut tellus elementum sagittis vitae et leo duis ut. Neque laoreet suspendisse interdum consectetur libero id faucibus nisl. Diam volutpat commodo sed egestas egestas. Dolor magna eget est lorem ipsum dolor. Vitae suscipit tellus mauris a diam maecenas sed. Turpis in eu mi bibendum neque egestas congue. Rhoncus est pellentesque elit ullamcorper dignissim cras lobortis.</section></div></div></div></div>
With native HTML dialog above code could be simplified to:
<dialog>
// dialog content + buttons goes here
</dialog>
The backdrop is customizable with CSS:
dialog::backdrop { /* example */background-color:rgba(0,0,0,.5);
backdrop-filter:blur(15px);
}
The text was updated successfully, but these errors were encountered:
Description
We can now use native HTML
dialog
tag in order to create modals.https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog
Why do you need this feature or component?
Using the native HTML
dialog
component means we can create modals without using a lot of custom markup (like a bunch ofdiv
elements). It comes standard with a backdrop customizable via CSS and accessibility features like focus and closing onESC
.Additional context
This is how Spectrum creates modals:
With native HTML dialog above code could be simplified to:
The backdrop is customizable with CSS:
The text was updated successfully, but these errors were encountered: