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<TLengthStyledSystem, Required<Theme<TLengthStyledSystem>>>-
isOpenbooleanCan be omitted if you want to do {isOpen && \<Modal />} instead
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
disableCloseOnEscbooleanIf `true`, hitting ESC key will not fire the `onClose` callback
wrapperProps(Pick<Pick<any, string | number | symbol> & Partial<Pick<any, never>>, string | number | symbol> & { theme?: any; } & { as?: string | ComponentClass<any, any> | FunctionComponent<...>; forwardedAs?: string | ... 1 more ... | FunctionComponent<...>; } & { ...; }) | (Pick<...> & ... 3 more ... & { ...; })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.