Dialog
Show content in a centered panel over a dimmed backdrop. Tapping the backdrop closes it.
Installation
Usage
[(open)]two-way binds a signal. Set it totrueto open the dialog andfalseto close it.- A backdrop tap sets
openback tofalse. Taps inside the panel don't reach the backdrop. - The backdrop fades in and the panel scales up. Closing plays the reverse.
- The dialog draws in an
<overlay>, so it covers the whole screen wherever it sits in your template. <ui-dialog-title>and<ui-dialog-description>render<text>, so put plain text in them. The footer lays out its buttons in a row, aligned right.
Run code after it closes
closed emits once the close animation has finished, about 270ms after open turns false. It fires from a timer, outside any tap handler, so it's a safe place to navigate.
To navigate straight from a button in the dialog instead, wrap the navigation in setTimeout. See the setTimeout rule for why.
Other content
Put any elements between the header and footer, such as a form. Import LYNX_ELEMENTS in your component for them.
Panel width
class goes on the panel, which is w-4/5 wide by default.
Make the user choose
A backdrop tap lets the user leave without choosing. When they must pick an action, such as confirming a delete, use Alert Dialog instead.
API
UiDialog
All sub-components (UiDialogHeader, UiDialogTitle, UiDialogDescription, UiDialogFooter) accept class.
Related
- Dialogs and overlays: how overlays work and which one to use
- Alert Dialog: a dialog the backdrop can't close
- Sheet: a panel from the bottom of the screen
<overlay>: the element the dialog draws in
