Basic usage

In it's current form, Modal is usable for single modals that you control yourself. While this is still in development, consider using jukwaa-ui if you require more advanced features.

import { Modal } from '@houzz/ui';

Close Icon

The close icon is supported through composition, using DismissButton.

import { Modal } from '@houzz/ui';

Accessibility

  • Make sure to specify a aria-labelledby attribute pointing to the ModalTitle
  • You may also specify a aria-describedby attribute
  • When modal is opened, should focus first interactive element
  • Content behind the modal should not be interactive
  • Focus should be trapped inside modal
  • When modal is closed, should return focus to previously focused element
  • Modal should be closed when clicking on Backdrop or when pressing ESC key

Modal best practices

Props

Modal
NameTypeDescription
gradientResponsiveValue<BackgroundProperty<TLengthStyledSystem>, Required<Theme<TLengthStyledSystem>>>-
children*ReactNodePrefer the following components when possible to get the correct styling \<ModalTitle /> \<ModalContent /> \<ModalActions />
isOpenbooleanCan be omitted if you want to do {isOpen && \<Modal />} instead
true
onClose*(event: MouseEvent | KeyboardEvent) => voidCalled when clicking outside the popover or when pressing the ESC key
disableCloseOnBackdropClickbooleanIf `true`, clicking on the backdrop will not fire the `onClose` callback
false
disableCloseOnEscbooleanIf `true`, hitting ESC key will not fire the `onClose` callback
false
role"dialog" | "alertdialog"Allows changing the 'dialog' role to 'alertdialog'. The alertdialog role is used to notify users of urgent information that demands the user's immediate attention. Examples include error messages that require confirmation and other action confirmation prompts. @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/dialog_role @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/alertdialog_role
"dialog"
wrapperPropsStyledComponentPropsWithAs<string | ComponentType<any>, any, BoxProps, never, string | ComponentType<any>> & { ...; }These props will be passed on the modal wrapper element. This can be used, for example, to add a custom class name or to override the z-index.