Dialog

Maintainer:
Alutery
GitHub
children
showError
hasCloseButton
disableOutsideClick
disableEscapeKeyDown
size
import {Dialog} from '@gravity-ui/uikit';

This is a component used for dialogs.

Usage

const [open, setOpen] = useState(false);
const dialogTitleId = 'app-confirmation-dialog-title';

<Dialog
  onClose={() => setOpen(false)}
  open={open}
  onEnterKeyDown={() => {
    alert('onEnterKeyDown');
  }}
  aria-labelledby={dialogTitleId}
>
  <Dialog.Header caption="Caption" id={dialogTitleId} />
  <Dialog.Body>Dialog.Body</Dialog.Body>
  <Dialog.Footer
    onClickButtonCancel={() => setOpen(false)}
    onClickButtonApply={() => alert('onApply')}
    textButtonApply="Apply"
    textButtonCancel="Cancel"
  />
</Dialog>;

Properties

NameDescriptionTypeDefault
openCurrent dialog stateBoolean
onEscapeKeyDownEscape keydown event handler(event: KeyboardEvent) => void
onEnterKeyDownEnter keydown event handler(event: KeyboardEvent) => void
onOutsideClickEvent handler on a mouse click outside the dialog(event: MouseEvent) => void
onCloseEvent handler on closing the dialog(event: MouseEvent or KeyboardEvent, reason: ModalCloseReason or "closeButtonClick") => void
classNameclassName of the dialog content wrapperString
modalClassNameclassName of modal box in which the dialog is embeddedString
sizeDialog sizes m l
disableBodyScrollLockToggles whether the body scroll is lockedBooleanFalse
disableEscapeKeyDownToggles whether the escape keydown is disabledBooleanFalse
disableOutsideClickToggles whether the outside click is disabledBooleanFalse
keepMountedToggles whether the dialog is kept in the mounted stateBooleanFalse
hasCloseButtonToggles whether there is a cross icon in the top-right corner of the dialogBooleanTrue
aria-labelledby<Dialog/> caption ID. Use the id property of <Dialog.Header/> to set the ID for captionString
aria-labelDialog label for a11y. Set aria-labelledby if the caption is visible to the userString
containerContainer element for the dialog boxHTMLElement
qadata-qa attribute value of the modal box in which the dialog is embeddedString
contentOverflowDetermines whether the Dialog has a scroll indicator inside or gets larger with the contentvisible autovisible