Skip to content

rux-dialog

A Rux dialog interrupts the app experience to prompt a user to confirm an action or acknowledge a piece of information. It displays information along with a set of buttons allowing users to “Accept or Cancel” the actions presented within the Rux dialog.

Guidelines

Web Components Usage

1. Installation

Download the Astro UXDS Component Library source to your project.

Via CLI:

sh
git clone https://github.com/RocketCommunicationsInc/astro-components.git
git clone https://github.com/RocketCommunicationsInc/astro-components.git

Or, download the Astro UXDS Components as a .zip

2. Import the Astro Rux Dialog Web Component

This example assumes you're using the NPM package in node_modules. Otherwise, import the component using the path to the Astro Components directory in your project.

javascript
import { RuxDialog } from '@astrouxds/rux-dialog/rux-dialog.js'
import { RuxDialog } from '@astrouxds/rux-dialog/rux-dialog.js'

3. Render the Astro Rux Dialog Web Component

Pass properties as attributes of the Astro Rux Dialog custom element:

xml
<rux-dialog
  title="dialog title"
  message="dialog message"
  confirmText="Ok"
  denyText="Cancel"
  customEvent="listen-for-me">
</rux-dialog>
<rux-dialog
  title="dialog title"
  message="dialog message"
  confirmText="Ok"
  denyText="Cancel"
  customEvent="listen-for-me">
</rux-dialog>

Or use slots to render the header, content and footer.

xml
<rux-dialog>
  <span slot="header">Slot Header</span>
  <p>Dialog Content as a slot</p>
  <div slot="footer">
    <rux-button secondary>Cancel</rux-button>
    <rux-button>Confrim</rux-button>
  </div>
</rux-dialog>
<rux-dialog>
  <span slot="header">Slot Header</span>
  <p>Dialog Content as a slot</p>
  <div slot="footer">
    <rux-button secondary>Cancel</rux-button>
    <rux-button>Confrim</rux-button>
  </div>
</rux-dialog>

Properties

PropertyAttributeDescriptionTypeDefault
clickToCloseclick-to-closeAllows dialog to close when clicking off itbooleanfalse
confirmTextconfirm-textText for confirmation buttonstring'Confirm'
denyTextdeny-textText for close buttonstring'Cancel'
headerheaderDialog header titlestring | undefinedundefined
messagemessageDialog body messagestring | undefinedundefined
openopenShows and hides dialogbooleanfalse

Events

EventDescriptionType
ruxdialogclosedEvent that is fired when dialog closes. If dialog is closed by clicking on the default confirm or deny buttons (when no footer slot is provided), then true or false will be emitted respectively on the event.detail.CustomEvent<boolean | null>
ruxdialogopenedEvent that is fired when dialog opensCustomEvent<void>

Slots

SlotDescription
"(default)"the dialog's message or content
"footer"the footer of the dialog
"header"the header of the dialog

Shadow Parts

PartDescription
"confirm-button"the dialog's confirm button
"container"the dialog container
"deny-button"the dialog's deny button
"dialog"the native dialog element
"footer"the footer of the dialog
"header"the header of the dialog
"message"the message of the dialog

Dependencies

Depends on

Graph

mermaid
graph TD;
  rux-dialog --> rux-button
  rux-button --> rux-icon
  style rux-dialog fill:#f9f,stroke:#333,stroke-width:4px
graph TD;
  rux-dialog --> rux-button
  rux-button --> rux-icon
  style rux-dialog fill:#f9f,stroke:#333,stroke-width:4px

Built with StencilJS