Command Palette

Search for a command to run...

Components · Complex component

Dialog

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

PropTypeDefaultDescription
as"button"'button'The HTML element or React element used to render the button, e.g. 'div', 'a', or `RouterLink`.
brandBgColorDesignTokenColor'accent-bright-2'A colour token that is acceptable by the brand. This colour will become the background color for the button.
brandTextColorDesignTokenColor'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-testidstring—Data attribute for E2E testing purposes.
disabledboolean—Whether the button is disabled. @extends jsdoc from AriaTextFieldProps[value]
fullWidthbooleanfalseSets button width to 100% of parent element
loadingboolean—Indicate loading state
loadingTextstring—Label used to control text of loading button.
onPress(event: PressEvent) => void—Handler that is called when the press is released over the target.
roundedbooleanfalseSet the radius of the button to a rounded variation.
sizeenum"lg"Predefined size value
variantenum'primary'The variant to use.

DialogClose

PropTypeDefaultDescription
as"button"'button'The HTML element or React element used to render the button, e.g. 'div', 'a', or `RouterLink`.
brandBgColorDesignTokenColor'accent-bright-2'A colour token that is acceptable by the brand. This colour will become the background color for the button.
brandTextColorDesignTokenColor'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-testidstring—Data attribute for E2E testing purposes.
disabledboolean—Whether the button is disabled. @extends jsdoc from AriaTextFieldProps[value]
fullWidthbooleanfalseSets button width to 100% of parent element
loadingboolean—Indicate loading state
loadingTextstring—Label used to control text of loading button.
onPress(event: PressEvent) => void—Handler that is called when the press is released over the target.
roundedbooleanfalseSet the radius of the button to a rounded variation.
sizeenum"lg"Predefined size value
variantenum'primary'The variant to use.