Arduino HomeDing Blog Archive

Thoughs and records on IoT, Web Sites and Microprocessors.

Dialogs and Data

Sketch of a dialog with data input elements

Using modal dialogs for capturing user input and data in a web application Using the <dialog> and <form> elements requires repeated JavaScript logic. This can be streamlined by creating web components that extend the standard elements.

Modal dialogs have long been unsupported as native UI elements in browsers. Many early attempts to implement modal dialogs relied on overlays and additional HTML elements to mimic modality. These solutions created elements on top of the existing HTML document to simulate modal behavior and these libraries can still be found in use as of today. Since 2022, most modern browsers widely support modal dialogs via the <dialog> element.

The [SFC library] now has 2 new components to support the use cases for dialogs with nested forms.

Modal Dialogs Best Practices

Using modal dialogs is sometimes, but not always, the best choice for user interactivity. In general, focusing the user’s attention on specific information, asking for input in a strict step-by-step process, or requesting confirmation can really raise user acceptance of a solution.

From my experience I like to see the following when using modal dialogs:

Dialogs and Data

Dialogs are often used for capturing or displaying data. Therefore many of them contain forms and functional buttons and this is maybe the most often used pattern of modal dialogs in general. This seems to be known to the people that have defined the standard elements of the Browser where “dialog” is a method of <form>. However the implementation is somehow incomplete and some common javascript is required to use “modal forms with dialogs”.

Here 2 custom elements help in the implementation

See also

[SFC library] [u-dialog-form component] [u-form-json component]

Tags

#sfc