Dialog
import {DialogModule} from "@qualcomm-ui/angular/dialog"Examples
Sizes
The dialog component has two sizes: sm and md. Size governs the width of the dialog, as well as the content's spacing, font size, and padding.
<div q-dialog-root size="sm">
<button emphasis="primary" q-button q-dialog-trigger variant="fill">
Open Dialog (sm)
</button>
<dialog-content-demo />
</div>Indicator Emphasis
Use the emphasis prop to change the intent and color of the dialog's indicator icon.
Custom Indicator
Set a custom indicator icon by providing the q-dialog-indicator-icon directive within the q-dialog-body directive. Or hide it entirely using the hideIndicatorIcon property on the q-dialog-body directive.
<div q-dialog-body>
<svg q-dialog-indicator-icon qIcon="AArrowDown"></svg>
<button q-dialog-close-button></button>
<h2 q-dialog-heading>Dialog Title</h2>
<div q-dialog-description>Dialog Description</div>
</div>Placement
Use the placement prop to change the placement of the dialog.
Controlled State
Dialog visibility can be controlled using the open, openChanged and defaultOpen properties. These properties follow our controlled state pattern.
Outside Scroll
The default scrollBehavior is outside, which makes the entire page scrollable when modal content exceeds viewport height. The modal and backdrop move with the page scroll instead of creating an internal scroll area within the modal.
Inside Scroll
Set the scrollBehavior prop to inside to create an internal scroll area within the modal.
Alert Dialog
Set the role prop to alertdialog to change the dialog component to an alert dialog. This is recommended for situations where the dialog is used to notify users of urgent information that demands their immediate attention.
Shortcuts
<q-dialog-floating-portal>
A helper component that combines the portal, positioner, and content components. This shortcut is equivalent to:
<q-portal>
<div q-dialog-backdrop></div>
<div q-dialog-positioner>
<section q-dialog-content><ng-content /></section>
</div>
</q-portal>API
<q-dialog-root>
| Prop | Type | Default |
|---|---|---|
Human-readable label for the dialog, used when the dialog title is not rendered | string | |
Whether to close the dialog when the escape key is pressed | boolean | true |
Whether to close the dialog when the outside is clicked | boolean | true |
The initial open state of the dialog when rendered.
Use when you don't need to control the open state of the dialog. | boolean | |
The document's text/writing direction. | 'ltr' | 'rtl' | "ltr" |
The style variant of the dialog's indicator. | | 'info' | 'neutral' |
Element to receive focus when the dialog is closed | () => HTMLElement | |
A root node to correctly resolve the Document in custom environments. i.e.,
Iframes, Electron. | () => | |
Whether to synchronize the present change immediately or defer it to the next
frame. | boolean | false |
Element to receive focus when the dialog is opened | () => HTMLElement | |
When true, the component will not be rendered in the DOM until it becomes
visible or active. | boolean | false |
Whether to prevent pointer interaction outside the element and hide all content
below it | boolean | true |
The controlled open state of the dialog | boolean | |
The persistent elements that: - should not have pointer-events disabled - should not trigger the dismiss event | Array< | |
The vertical placement of the dialog within the viewport. | | 'top' | 'top' |
The controlled presence of the node. | boolean | |
Whether to prevent scrolling behind the dialog when it's opened | boolean | true |
Whether to restore focus to the element that had focus before the dialog was
opened | boolean | true |
The dialog's role | | 'dialog' | 'dialog' |
Defines the scroll behavior of the dialog content when modal content exceeds
viewport height. | | 'inside' | 'outside' |
The size of the dialog's content area and fonts. A smaller size uses less
horizontal space. | 'sm' | 'md' | 'sm' |
Whether to allow the initial presence animation. | boolean | false |
Whether to trap focus inside the dialog when it's opened | boolean | true |
When true, the component will be completely removed from the DOM when it
becomes inactive or hidden, rather than just being hidden with CSS. | boolean | false |
Function called when the escape key is pressed | KeyboardEvent | |
Function called when the animation ends in the closed state | void | |
Function called when the focus is moved outside the component | CustomEvent<{ | |
Function called when an interaction happens outside the component | | CustomEvent<{event?: E}> | |
Fired when the dialog opens or closes. | boolean | |
Function called when the pointer is pressed down outside the component | CustomEvent<{ | |
Function called when this layer is closed due to a parent layer being closed | CustomEvent<{ |
stringbooleanbooleanboolean'ltr' | 'rtl'
| 'info'
| 'success'
| 'warning'
| 'danger'
| 'neutral'
() => HTMLElement
() =>
| Node
| ShadowRoot
| Document
boolean() => HTMLElement
booleanbooleanbooleanArray<
() => Element
>
- should not have pointer-events disabled
- should not trigger the dismiss event
| 'top'
| 'center'
| 'bottom'
booleanbooleanboolean| 'dialog'
| 'alertdialog'
| 'inside'
| 'outside'
'sm' | 'md'
booleanbooleanbooleanKeyboardEventvoidCustomEvent<{
event?: E
}>
| CustomEvent<{event?: E}>
| CustomEvent<{event?: E}>
booleanCustomEvent<{
event?: E
}>
CustomEvent<{
originalIndex: number
originalLayer: HTMLElement
targetIndex: number
targetLayer: HTMLElement
}>
<q-dialog-floating-portal>
q-dialog-backdrop
DialogBackdropComponent| Attribute / Property | Value |
|---|---|
class | 'qui-dialog__backdrop' |
data-part | 'backdrop' |
data-scope | 'dialog' |
data-state | | 'open' |
hidden | boolean |
class'qui-dialog__backdrop'data-part'backdrop'data-scope'dialog'data-state| 'open'
| 'closed'
hiddenbooleanq-dialog-positioner
| Prop | Type |
|---|---|
id attribute. If
omitted, a unique identifier will be generated for accessibility. | string |
string| Attribute / Property | Value |
|---|---|
class | 'qui-dialog__positioner' |
data-part | 'positioner' |
data-placement | | 'top' |
data-scope | 'dialog' |
data-scroll-behavior | | 'inside' |
data-size | 'sm' | 'md' |
style |
class'qui-dialog__positioner'data-part'positioner'data-placement| 'top'
| 'center'
| 'bottom'
data-scope'dialog'data-scroll-behavior| 'inside'
| 'outside'
data-size'sm' | 'md'
styleq-dialog-content
| Prop | Type |
|---|---|
id attribute. If
omitted, a unique identifier will be generated for accessibility. | string |
string| Attribute / Property | Value |
|---|---|
class | 'qui-dialog__content' |
data-part | 'content' |
data-scope | 'dialog' |
data-scroll-behavior | | 'inside' |
data-size | 'sm' | 'md' |
data-state | | 'open' |
hidden | boolean |
tabIndex | -1 |
class'qui-dialog__content'data-part'content'data-scope'dialog'data-scroll-behavior| 'inside'
| 'outside'
data-size'sm' | 'md'
data-state| 'open'
| 'closed'
hiddenbooleantabIndex-1
q-dialog-body
| Prop | Type |
|---|---|
Hides the indicator icon. | boolean |
boolean| Attribute / Property | Value |
|---|---|
class | 'qui-dialog__body' |
data-part | 'body' |
data-scope | 'dialog' |
data-size | 'sm' | 'md' |
class'qui-dialog__body'data-part'body'data-scope'dialog'data-size'sm' | 'md'
q-dialog-heading
| Prop | Type |
|---|---|
id attribute. If
omitted, a unique identifier will be generated for accessibility. | string |
string| Attribute / Property | Value |
|---|---|
class | 'qui-dialog__heading' |
data-part | 'heading' |
data-scope | 'dialog' |
data-size | 'sm' | 'md' |
class'qui-dialog__heading'data-part'heading'data-scope'dialog'data-size'sm' | 'md'
q-dialog-footer
| Attribute / Property | Value |
|---|---|
class | 'qui-dialog__footer' |
data-part | 'footer' |
data-scope | 'dialog' |
data-size | 'sm' | 'md' |
class'qui-dialog__footer'data-part'footer'data-scope'dialog'data-size'sm' | 'md'
q-dialog-indicator-icon
| Attribute / Property | Value |
|---|---|
class | 'qui-dialog__indicator-icon' |
data-emphasis | | 'info' |
data-size | 'sm' | 'md' |
class'qui-dialog__indicator-icon'data-emphasis| 'info'
| 'success'
| 'warning'
| 'danger'
| 'neutral'
data-size'sm' | 'md'
q-dialog-close-button
| Prop | Type |
|---|---|
id attribute. If
omitted, a unique identifier will be generated for accessibility. | string |
string| Attribute / Property | Value |
|---|---|
class | 'qui-dialog__close-button' |
data-part | 'close-trigger' |
data-scope | 'dialog' |
class'qui-dialog__close-button'data-part'close-trigger'data-scope'dialog'