Dialog is a utility component for building a variety of floating elements as alerts, modals, popovers etc. Dialog is designed to simplify the creation of modals, popovers, and other overlay elements. Try not to use dialog directly and only resort to using this when you need more control over the presentation and behavior of the overlay.
Usage
TSX
import { Dialog } from '@console/nimbus-ui/core';Features
The HTML <dialog> element can be used to build dialogs. However, it is not yet widely supported across browsers, and building fully accessible custom dialogs from scratch is very difficult and error prone. Dialog helps achieve accessible dialogs that can be styled as needed.
- Flexible – Dialogs can be used within a Modal or Popover to create many types of overlay elements.
- Accessible – Exposed to assistive technology as a dialog or alertdialog with ARIA. The dialog is automatically labeled by a nested
<Heading>element. Content outside the dialog is hidden from assistive technologies while it is open. - Focus management – Focus is moved into the dialog on mount, and restored to the trigger element on unmount. While open, focus is contained within the dialog, preventing the user from tabbing outside.
Examples
API
Dialog
Dialog.Close
| Prop | Type | Default | Description |
|---|---|---|---|
| as | "button" | 'button' | The HTML element or React element used to render the button, e.g. 'div', 'a', or `RouterLink`. |
| brandBgColor | DesignTokenColor | 'accent-bright-2' | A colour token that is acceptable by the brand. This colour will become the background color for the button. |
| brandTextColor | DesignTokenColor | 'text-100' | A colour token that is acceptable by the brand. This colour will become the text color for the button. Console usually provides light colours |
| classes | { root?: string; text?: string; } | — | |
| data-testid | string | — | Data attribute for E2E testing purposes. |
| disabled | boolean | — | Whether the button is disabled. @extends jsdoc from AriaTextFieldProps[value] |
| fullWidth | boolean | false | Sets button width to 100% of parent element |
| loading | boolean | — | Indicate loading state |
| loadingText | string | — | Label used to control text of loading button. |
| onPress | (event: PressEvent) => void | — | Handler that is called when the press is released over the target. |
| rounded | boolean | false | Set the radius of the button to a rounded variation. |
| size | enum | "lg" | Predefined size value |
| variant | enum | 'primary' | The variant to use. |
DialogClose
| Prop | Type | Default | Description |
|---|---|---|---|
| as | "button" | 'button' | The HTML element or React element used to render the button, e.g. 'div', 'a', or `RouterLink`. |
| brandBgColor | DesignTokenColor | 'accent-bright-2' | A colour token that is acceptable by the brand. This colour will become the background color for the button. |
| brandTextColor | DesignTokenColor | 'text-100' | A colour token that is acceptable by the brand. This colour will become the text color for the button. Console usually provides light colours |
| classes | { root?: string; text?: string; } | — | |
| data-testid | string | — | Data attribute for E2E testing purposes. |
| disabled | boolean | — | Whether the button is disabled. @extends jsdoc from AriaTextFieldProps[value] |
| fullWidth | boolean | false | Sets button width to 100% of parent element |
| loading | boolean | — | Indicate loading state |
| loadingText | string | — | Label used to control text of loading button. |
| onPress | (event: PressEvent) => void | — | Handler that is called when the press is released over the target. |
| rounded | boolean | false | Set the radius of the button to a rounded variation. |
| size | enum | "lg" | Predefined size value |
| variant | enum | 'primary' | The variant to use. |
React Aria