Skip to main content

fast-dialog

As defined by the W3C:

A dialog is a window overlaid on either the primary window or another dialog window. Windows under a modal dialog are inert. That is, users cannot interact with content outside an active dialog window. Inert content outside an active dialog is typically visually obscured or dimmed so it is difficult to discern, and in some implementations, attempts to interact with the inert content cause the dialog to close.

Like non-modal dialogs, modal dialogs contain their tab sequence. That is, Tab and Shift + Tab do not move focus outside the dialog. However, unlike most non-modal dialogs, modal dialogs do not provide means for moving keyboard focus outside the dialog window without closing the dialog.

Setup#

import {    provideFASTDesignSystem,    fastDialog} from "@microsoft/fast-components";
provideFASTDesignSystem()    .register(        fastDialog()    );

Usage#

<fast-dialog id="example1" class="example-dialog" aria-label="Simple modal dialog" modal="true" hidden>    <h2>Dialog</h2>    <p>This is an example dialog.</p>    <fast-button>Close Dialog</fast-button></fast-dialog>

Create your own design#

import { Dialog, dialogTemplate as template } from "@microsoft/fast-foundation";import { dialogStyles as styles } from "./my-dialog.styles";
export const myDialog = Dialog.compose({    baseName: "dialog",    template,    styles,});

Additional resources#