Alert Dialog

A modal dialog that interrupts the user with important content and expects a response.

Installation

ng g @spartan-ng/cli:ui alert-dialog

Usage

import { HlmAlertDialogImports } from '@spartan-ng/helm/alert-dialog';
<hlm-alert-dialog>
  <button hlmAlertDialogTrigger hlmBtn variant="outline">Show Dialog</button>
  <hlm-alert-dialog-content *hlmAlertDialogPortal="let ctx">
    <hlm-alert-dialog-header>
      <h2 hlmAlertDialogTitle>Are you absolutely sure?</h2>
      <p hlmAlertDialogDescription>This action cannot be undone. This will permanently delete your account from our servers.</p>
    </hlm-alert-dialog-header>
    <hlm-alert-dialog-footer>
      <button hlmAlertDialogCancel>Cancel</button>
      <button hlmAlertDialogAction>Continue</button>
    </hlm-alert-dialog-footer>
  </hlm-alert-dialog-content>
</hlm-alert-dialog>

Examples

Small

Use the size="sm" prop to make the alert dialog smaller.

Media

Use the hlm-alert-dialog-media component to add a media element such as an icon or image to the alert dialog.

Small with Media

Use the size="sm" prop to make the alert dialog smaller and the hlm-alert-dialog-media component to add a media element such as an icon or image to the alert dialog.

Destructive

Use hlmAlertDialogAction with the variant="destructive" prop to indicate a destructive action.

Use hlmAlertDialogTriggerFor on a menu item to open an alert dialog from a dropdown menu.

RTL

To enable RTL support in spartan-ng, see the RTL configuration guide.

Brain API

BrnAlertDialogContent

Selector: [brnAlertDialogContent]

Inputs

PropTypeDefaultDescription
class string | null | undefined undefined -
context T | undefined undefined -

BrnAlertDialogDescription

Selector: [brnAlertDialogDescription]

BrnAlertDialogOverlay

Selector: [brnAlertDialogOverlay],brn-alert-dialog-overlay

Inputs

PropTypeDefaultDescription
class string | null | undefined undefined -

BrnAlertDialogTitle

Selector: [brnAlertDialogTitle]

BrnAlertDialogTrigger

Selector: button[brnAlertDialogTrigger],button[brnAlertDialogTriggerFor]

Inputs

PropTypeDefaultDescription
brnAlertDialogTriggerFor BrnAlertDialog | undefined --
id string `brn-dialog-trigger-${++triggerIdSequence}` -
type 'button' | 'submit' | 'reset' 'button' -
brnDialogTriggerFor BrnDialog | undefined undefined -

BrnAlertDialog

Selector: [brnAlertDialog],brn-alert-dialog

ExportAs: brnAlertDialog

Inputs

PropTypeDefaultDescription
id string `brn-dialog-${++dialogIdSequence}` -
state BrnDialogState | null null -
role BrnDialogOptions['role'] this._defaultOptions.role -
hasBackdrop boolean this._defaultOptions.hasBackdrop -
positionStrategy BrnDialogOptions['positionStrategy'] this._defaultOptions.positionStrategy -
scrollStrategy BrnDialogOptions['scrollStrategy'] | 'close' | 'reposition' | null this._defaultOptions.scrollStrategy -
restoreFocus BrnDialogOptions['restoreFocus'] this._defaultOptions.restoreFocus -
closeOnOutsidePointerEvents boolean this._defaultOptions.closeOnOutsidePointerEvents -
attachTo BrnDialogOptions['attachTo'] this._defaultOptions.attachTo -
attachPositions BrnDialogOptions['attachPositions'] this._defaultOptions.attachPositions -
autoFocus BrnDialogOptions['autoFocus'] this._defaultOptions.autoFocus -
disableClose boolean this._defaultOptions.disableClose -
aria-describedby BrnDialogOptions['ariaDescribedBy'] this._defaultOptions.ariaDescribedBy -
aria-labelledby BrnDialogOptions['ariaLabelledBy'] this._defaultOptions.ariaLabelledBy -
aria-label BrnDialogOptions['ariaLabel'] this._defaultOptions.ariaLabel -
aria-modal boolean this._defaultOptions.ariaModal -

Outputs

PropTypeDefaultDescription
closed TResult --
stateChanged BrnDialogState --

Helm API

HlmAlertDialogAction

Selector: button[hlmAlertDialogAction]

Inputs

PropTypeDefaultDescription
type 'button' | 'submit' | 'reset' 'button' -
variant ButtonVariants['variant'] this._config.variant -
size ButtonVariants['size'] this._config.size -

HlmAlertDialogCancel

Selector: button[hlmAlertDialogCancel]

Inputs

PropTypeDefaultDescription
type 'button' | 'submit' | 'reset' 'button' -
variant ButtonVariants['variant'] this._config.variant -
size ButtonVariants['size'] this._config.size -

HlmAlertDialogContent

Selector: [hlmAlertDialogContent],hlm-alert-dialog-content

Inputs

PropTypeDefaultDescription
size 'sm' | 'default' 'default' -

HlmAlertDialogDescription

Selector: [hlmAlertDialogDescription]

HlmAlertDialogFooter

Selector: [hlmAlertDialogFooter],hlm-alert-dialog-footer

HlmAlertDialogHeader

Selector: [hlmAlertDialogHeader],hlm-alert-dialog-header

HlmAlertDialogMedia

Selector: [hlmAlertDialogMedia],hlm-alert-dialog-media

HlmAlertDialogOverlay

Selector: [hlmAlertDialogOverlay],hlm-alert-dialog-overlay

Inputs

PropTypeDefaultDescription
class ClassValue '' -

HlmAlertDialogPortal

Selector: [hlmAlertDialogPortal]

Inputs

PropTypeDefaultDescription
context T | undefined undefined -
class string | null | undefined undefined -

HlmAlertDialogTitle

Selector: [hlmAlertDialogTitle]

HlmAlertDialogTrigger

Selector: button[hlmAlertDialogTrigger],button[hlmAlertDialogTriggerFor]

Inputs

PropTypeDefaultDescription
id string `brn-dialog-trigger-${++triggerIdSequence}` -
hlmAlertDialogTriggerFor BrnAlertDialog | undefined --
type 'button' | 'submit' | 'reset' 'button' -

HlmAlertDialog

Selector: hlm-alert-dialog

ExportAs: hlmAlertDialog

Inputs

PropTypeDefaultDescription
id string `brn-dialog-${++dialogIdSequence}` -
state BrnDialogState | null null -
role BrnDialogOptions['role'] this._defaultOptions.role -
hasBackdrop boolean this._defaultOptions.hasBackdrop -
positionStrategy BrnDialogOptions['positionStrategy'] this._defaultOptions.positionStrategy -
scrollStrategy BrnDialogOptions['scrollStrategy'] | 'close' | 'reposition' | null this._defaultOptions.scrollStrategy -
restoreFocus BrnDialogOptions['restoreFocus'] this._defaultOptions.restoreFocus -
closeOnOutsidePointerEvents boolean this._defaultOptions.closeOnOutsidePointerEvents -
attachTo BrnDialogOptions['attachTo'] this._defaultOptions.attachTo -
attachPositions BrnDialogOptions['attachPositions'] this._defaultOptions.attachPositions -
autoFocus BrnDialogOptions['autoFocus'] this._defaultOptions.autoFocus -
disableClose boolean this._defaultOptions.disableClose -
aria-describedby BrnDialogOptions['ariaDescribedBy'] this._defaultOptions.ariaDescribedBy -
aria-labelledby BrnDialogOptions['ariaLabelledBy'] this._defaultOptions.ariaLabelledBy -
aria-label BrnDialogOptions['ariaLabel'] this._defaultOptions.ariaLabel -
aria-modal boolean this._defaultOptions.ariaModal -

Outputs

PropTypeDefaultDescription
closed TResult --
stateChanged BrnDialogState --
Aspect Ratio Alert