Most of these user interface elements
are added to web applications
using either custom JavaScript
or common libraries.
With that route there’s a lot
to make sure that you
or the library you choose gets right.
The <dialog> element
and the popover attribute
are two Baseline layered UI patterns
that developers can reach
for instead of custom implementations.
To show the advantages
of using layered UI patterns built
into today’s web browsers –
and to give an example
of when you might reach for <dialog>
or use the popover attribute –
this article walks through
an example of a modal
that appears when the user attempts
to save an image
to a favorites list without being logged in.
Article contents
- A modal
<dialog>
- How to close the dialog
popover, rising to the top
- Autofocus
- Style the
::backdrop
- Make an entrance (and exit) with
@starting-style
The demo where we put it all together
See the Pen Baseline dialog demo by @web-dot-dev on CodePen.
Read full article »