Dialog
The Dialog component is a flexible and extensible content container overlaid on either the primary window or another dialog. It is based on the HTML <dialog> element and can be used to create both modal and non-modal dialog boxes. Modal dialog boxes interrupt interaction with the rest of the page being inert, while non-modal dialog boxes allow interaction with the rest of the page. Inert content outside an active dialog box is usually visually obscured or dimmed, making it difficult to discern. By default, modal overlays contain their own tab sequence, preventing users from navigating outside the component. The component implements the W3C ARIA APG Dialog (Modal) Pattern as well as the W3C ARIA APG Alert and Message Dialogs Pattern.
Examples
Base
A dialog is seperated into header, body and footer sections, which can be defined separately either through properties or template slots.
Be sure to provide a mechanism that allows users to close the dialog. The most reliable way to enable all users to close the dialogue box is to include an explicit button for this purpose, such as a 'Confirm', 'Cancel' or 'Close' button. The component specifies different types of user action that can be used to close the dialogue box. The main closeable property will add a close button to the dialog header. The closeOnBackdrop property adds a a light dismiss user action, which closes the dialog box when the user clicks or taps outside of it. The closeOnEscape property allows platform-specific user actions, such as pressing the ESC key on desktop platforms, or performing a "back" or "dismiss" gesture on mobile platforms, to close the dialog box. Furthermore, by setting the cancelButton or confirmButton properties, associated buttons will be rendered in the footer section. With closeOnConfirm, the confirm button can also be used to close the dialog.
Modal
A simple modal dialog box is created by setting the backdrop property, which inert the background. By default, attempting to interact with the backdrop closes the dialog box. Setting the blockScroll property removes the body scrollbar. However, the body retains a non-scrollable scrollbar to prevent the background from shifting. This will set the body to position="fixed", which may cause some layouts to break.
Alert
An alert dialog box is a modal dialog that interrupts the user's workflow to communicate an important message and acquire a response. It is defined by setting the alert property. Examples include action confirmation prompts and error message confirmations. The dialog will have the alertdialog WAI-ARIA role, enabling assistive technologies and browsers to distinguish it from other dialogs and giving them the option to treat it specially, e.g. by playing a system alert sound.
Form
One useful purpose of a dialog is to display forms within it. Each slot provides the close() and confirm()functions, which can be called from inside the slot content to trigger component events. Using the autofocus attribute to explicitly indicate the initial focus placement will help ensure the focus is initially set on the focusable element deemed to be the best initial focus placement for any particular dialog.
Fullscreen
Another variant of the component is the option to display a dialog that covers the full user viewport, which is available via the fullscreen property.
Image
The component provides a separate image section in the body where an image can be placed using the imageSrc property. For accessibility reasons, don't forget to add an imageAlt property too.
Position
You can quickly change the alignment of all the text in the dialog box using the textPosition property. Additionally, you can align the footer buttons independently using the buttonPosition property.
Slots
The component provides header, title, subtitle, content, footer as well as confirmButton and cancelButton named slots templates to customise HTML content.
Dynamic Component
Rather than using the default slot, the component prop allows to pass any component that will be programmatically rendered inside the dialog component. Furthermore, an inline component created with a render function can also be passed. Props and events can be passed to the component with props and events properties too.
Teleport
The teleport prop allows the dialog to be "teleported" into any DOM node outside the DOM hierarchy of the component placed in. By default, if only a boolean is passed, the diaog will be teleported to the document body. In addition, any other destination could be passed as string or the DOM Node element.
Programmatically
This component provides a programmatic interface that can be accessed by the useOruga() composable. The composable can be used from outside of the Vue instance. For example, it can be used in Pinia or Vue Router with this syntax:
import { useOruga } from "@oruga-ui/oruga-next";
const oruga = useOruga();
oruga.dialog.open({...});
A programmatic instance returns a promise to await for. The promise gets resolved when the dialog gets closed.
Dialog Component
Dialog is a container to display content in an overlay window.
<o-dialog></o-dialog>Props
| Prop name | Description | Type | Values | Default |
|---|---|---|---|---|
| active | Whether dialog is active or not, use v-model:active to make it two-way binding | boolean | - | false |
| alert | This enables the alertdialog role, allowing assistive technologies and browsers to distinguish alert dialogs from other dialogs.Alert dialogs interrupt the user's workflow to communicate an important messages and acquire an explicit response. Examples include error messages that require confirmation and other action confirmation prompts. | boolean | - | |
| animation | Custom animation (transition name) | string | - | From config: dialog: { |
| ariaCloseLabel | Accessibility label for the close button | string | - | From config: dialog: { |
| ariaDescribedby | Accessibility aria-describedby to be passed to the div root element - if a title is set, it is linked to the title | string | - | |
| ariaLabel | Accessibility aria-label to be passed to the div root element | string | - | |
| backdrop | Show an backdrop overlay background; make it a modal dialog | boolean | - | From config: dialog: { |
| blockScroll | Whether background scrollbar should be blocked/removed when dialog is visible | boolean | - | From config: dialog: { |
| buttonPosition | Position of the footer buttons | "center" | "left" | "right" | - | |
| cancelButton | Render a cancel button and set text text as label | string | - | |
| cancelVariant | Color variant of the cancel button | string | primary, info, success, warning, danger, and any other custom color | |
| closeIcon | Close icon name | string | - | From config: dialog: { |
| closeIconSize | Close icon size | string | - | From config: dialog: { |
| closeOnBackdrop | Close the dialog when clicked outside of the panel | boolean | - | From config: dialog: { |
| closeOnConfirm | Close the dialog when the confirm button is preset | boolean | - | From config: dialog: { |
| closeOnEscape | Close the dialog when pressing escape key | boolean | - | From config: dialog: { |
| closeable | Adds close button to the header to hide the dialog | boolean | - | From config: dialog: { |
| component | Component to be injected. Close the component by emitting a 'close' event — $emit('close') | Component | - | |
| confirmButton | Render a confirm button and set text as label | string | - | |
| confirmVariant | Color variant of the confirm button | string | primary, info, success, warning, danger, and any other custom color | |
| content | Dialog body content, unnecessary when content slot is used | string | - | |
| disableCancel | Disable the cancel button | boolean | - | |
| disableConfirm | Disable the confirm button | boolean | - | |
| events | Events to be binded to the injected component | {} | - | |
| fullscreen | Display dialog as full screen | boolean | - | false |
| iconPack | Icon pack to use for the close icon | string | mdi, fa, fas and any other custom icon pack | From config: dialog: { |
| imageAlt | Dialog image alt, unnecessary when image slot is used | string | - | |
| imageSrc | Dialog image src, unnecessary when image slot is used | string | - | |
| loading | Show a loading spinner in the dialog | boolean | - | |
| loadingLabel | Show label beside the loading icon | string | - | |
| maxHeight | Max height of the dialog | Numberish | - | From config: dialog: { |
| maxWidth | Max width of the dialog | Numberish | - | From config: dialog: { |
| mobileBreakpoint | Mobile breakpoint as max-width value | string | - | From config: dialog: { |
| override | Override existing theme classes completely | boolean | - | |
| props | Props to be binded to the injected component | any | - | |
| subtitle | Dialog header subtitle, unnecessary when subtitle slot is used | string | - | |
| teleport | Append the component to another part of the DOM. Set true to append the component to the body.In addition, any CSS selector string or an actual DOM node can be used. | boolean | object | string | - | From config: dialog: { |
| textPosition | Text alignment in its entirely | "center" | "left" | "right" | - | |
| title | Dialog header title, unnecessary when title slot is used | string | - |
Events
| Event name | Properties | Description |
|---|---|---|
| update:active | value boolean - updated active prop | active prop two-way binding |
| close | event Event - native event | the event is fired when the dialog has been closed |
| cancel | event Event - native event | the event is fired when the user wish to dismiss the current open dialog |
| confirm | event Event - native event | the event is fired when the confirm button get clicked |
Slots
| Name | Description | Bindings |
|---|---|---|
| header | Override the header | close (event: Event): void - function to emit a close event |
| title | Override the header title, default is title prop | |
| subtitle | Override the header subtitle, default is subtitle prop | |
| close | Define a custom close icon | |
| image | Override the image | |
| default | Override the default dialog body | close (event: Event): void - function to emit a close eventconfirm (event: Event): void - function to emit a confirm event |
| content | Override the body content, default is content prop | close (event: Event): void - function to emit a close eventconfirm (event: Event): void - function to emit a confirm event |
| footer | Override the footer | close (event: Event): void - function to emit a close eventconfirm (event: Event): void - function to emit a confirm event |
| cancelButton | Define the cancel button label | |
| confirmButton | Define the confirm button label |
Class Inspector
| Class prop | Description | Props | Suffixes | |
|---|---|---|---|---|
| rootClass | Class of the root element. | |||
| mobileClass | Class of the root element when on mobile. 👉 Switch to mobile view to see it in action! | |||
| activeClass | Class of the root element when active. | active | ||
| fullscreenClass | Class of the root element when fullscreen. | fullscreen | ||
| teleportClass | Class of the root element when teleported. | teleport | ||
| textPositionClass | Class of the root element with text position. | textPosition | left | |
| backdropClass | Class of the backdrop overlay element. | backdrop | ||
| wrapperClass | Class of the wrapper element. | |||
| headerClass | Class of the header element. | |||
| titleClass | Class of the header title element. | |||
| subtitleClass | Class of the header subtitle element. | |||
| closeClass | Class of the header close element. | |||
| figureClass | Class of the image figure element. | |||
| imageClass | Class of the image element. | |||
| bodyClass | Class of the body element. | |||
| contentClass | Class of the body content element. | |||
| footerClass | Class of the footer element. | |||
| footerPositionClass | Class of the footer element with position. | buttonPosition | left | |
| confirmButtunClass | Class of the footer confirm button element. | confirmButton | ||
| cancelButtonClass | Class of the footer cancel button element. | cancelButton | ||
| scrollClipClass | Class of the body when dialog is active and has blockScroll. | blockScroll | ||
| scrollKeepClass | Class of the body when dialog is active and has not blockScroll. | blockScroll |
Sass Variables
Current theme ➜ Oruga
The theme does not have any custom variables for this component.
Current theme ➜ Bulma
The theme does not have any custom variables for this component.
Current theme ➜ Bootstrap
The theme does not have any custom variables for this component.
