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>

The root component that provides context for the dialog and its parts.
PropTypeDefault
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'
| 'success'
| 'warning'
| 'danger'
| 'neutral'
'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.
() =>
| Node
| ShadowRoot
| Document
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<
() => Element
>
The vertical placement of the dialog within the viewport.
  • 'top': The dialog is positioned at the top of the viewport.
  • 'center': The dialog is positioned at the center of the viewport.
  • 'bottom': The dialog is positioned at the bottom of the viewport.
| 'top'
| 'center'
| 'bottom'
'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'
| 'alertdialog'
'dialog'
Defines the scroll behavior of the dialog content when modal content exceeds viewport height.
  • 'inside': The modal and backdrop create an internal scroll area within the modal.
  • 'outside': The modal and backdrop move with the page scroll instead of creating an internal scroll area within the modal.
| 'inside'
| 'outside'
'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<{
event?: E
}>
Function called when an interaction happens outside the component
| CustomEvent<{event?: E}>
| CustomEvent<{event?: E}>
Fired when the dialog opens or closes.
boolean
Function called when the pointer is pressed down outside the component
CustomEvent<{
event?: E
}>
Function called when this layer is closed due to a parent layer being closed
CustomEvent<{
originalIndex: number
originalLayer: HTMLElement
targetIndex: number
targetLayer: HTMLElement
}>
Type
string
Description
Human-readable label for the dialog, used when the dialog title is not rendered
Type
boolean
Description
Whether to close the dialog when the escape key is pressed
Type
boolean
Description
Whether to close the dialog when the outside is clicked
Type
boolean
Description
The initial open state of the dialog when rendered. Use when you don't need to control the open state of the dialog.
Type
'ltr' | 'rtl'
Description
The document's text/writing direction.
Type
| 'info'
| 'success'
| 'warning'
| 'danger'
| 'neutral'
Description
The style variant of the dialog's indicator.
Type
() => HTMLElement
Description
Element to receive focus when the dialog is closed
Type
() =>
| Node
| ShadowRoot
| Document
Description
A root node to correctly resolve the Document in custom environments. i.e., Iframes, Electron.
Type
boolean
Description
Whether to synchronize the present change immediately or defer it to the next frame.
Type
() => HTMLElement
Description
Element to receive focus when the dialog is opened
Type
boolean
Description
When true, the component will not be rendered in the DOM until it becomes visible or active.
Type
boolean
Description
Whether to prevent pointer interaction outside the element and hide all content below it
Type
boolean
Description
The controlled open state of the dialog
Type
Array<
() => Element
>
Description
The persistent elements that:
- should not have pointer-events disabled
- should not trigger the dismiss event
Type
| 'top'
| 'center'
| 'bottom'
Description
The vertical placement of the dialog within the viewport.
  • 'top': The dialog is positioned at the top of the viewport.
  • 'center': The dialog is positioned at the center of the viewport.
  • 'bottom': The dialog is positioned at the bottom of the viewport.
Type
boolean
Description
The controlled presence of the node.
Type
boolean
Description
Whether to prevent scrolling behind the dialog when it's opened
Type
boolean
Description
Whether to restore focus to the element that had focus before the dialog was opened
Type
| 'dialog'
| 'alertdialog'
Description
The dialog's role
Type
| 'inside'
| 'outside'
Description
Defines the scroll behavior of the dialog content when modal content exceeds viewport height.
  • 'inside': The modal and backdrop create an internal scroll area within the modal.
  • 'outside': The modal and backdrop move with the page scroll instead of creating an internal scroll area within the modal.
Type
'sm' | 'md'
Description
The size of the dialog's content area and fonts. A smaller size uses less horizontal space.
Type
boolean
Description
Whether to allow the initial presence animation.
Type
boolean
Description
Whether to trap focus inside the dialog when it's opened
Type
boolean
Description
When true, the component will be completely removed from the DOM when it becomes inactive or hidden, rather than just being hidden with CSS.
Type
KeyboardEvent
Description
Function called when the escape key is pressed
Type
void
Description
Function called when the animation ends in the closed state
Type
CustomEvent<{
event?: E
}>
Description
Function called when the focus is moved outside the component
Type
| CustomEvent<{event?: E}>
| CustomEvent<{event?: E}>
Description
Function called when an interaction happens outside the component
Type
boolean
Description
Fired when the dialog opens or closes.
Type
CustomEvent<{
event?: E
}>
Description
Function called when the pointer is pressed down outside the component
Type
CustomEvent<{
originalIndex: number
originalLayer: HTMLElement
targetIndex: number
targetLayer: HTMLElement
}>
Description
Function called when this layer is closed due to a parent layer being closed

<q-dialog-floating-portal>

A helper component that combines the portal, positioner, and content components.
PropType
Override the element that the portal is attached to.
| HTMLElement
| ElementRef<HTMLElement>
Set this to true to disable portalling behavior, causing the children to be rendered as-is.
boolean
Type
| HTMLElement
| ElementRef<HTMLElement>
Description
Override the element that the portal is attached to.
Type
boolean
Description
Set this to true to disable portalling behavior, causing the children to be rendered as-is.

q-dialog-backdrop

Entity not found: DialogBackdropComponent

q-dialog-positioner

A container for the dialog content that handles positioning.
PropType
id attribute. If omitted, a unique identifier will be generated for accessibility.
string
Type
string
Description
id attribute. If omitted, a unique identifier will be generated for accessibility.

q-dialog-content

A container for the dialog contents.
PropType
id attribute. If omitted, a unique identifier will be generated for accessibility.
string
Type
string
Description
id attribute. If omitted, a unique identifier will be generated for accessibility.

q-dialog-body

The main content of the dialog. Container for the heading, description, indicator, and primary content of the dialog.
PropType
Hides the indicator icon.
boolean
Type
boolean
Description
Hides the indicator icon.

q-dialog-heading

A heading that labels the dialog.
PropType
id attribute. If omitted, a unique identifier will be generated for accessibility.
string
Type
string
Description
id attribute. If omitted, a unique identifier will be generated for accessibility.
The footer section of the dialog. Typically contains action buttons.

q-dialog-indicator-icon

An icon that indicates the dialog's status.

q-dialog-close-button

A button that closes the dialog.
PropType
id attribute. If omitted, a unique identifier will be generated for accessibility.
string
Type
string
Description
id attribute. If omitted, a unique identifier will be generated for accessibility.