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-labelledbyattribute pointing to the ModalTitle - You may also specify a
aria-describedbyattribute - 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
ESCkey
Props
Modal| Name | Type | Description |
gradient | ResponsiveValue<TLengthStyledSystem, Required<Theme<TLengthStyledSystem>>> | - |
isOpen | boolean | Can be omitted if you want to do {isOpen && \<Modal />} instead |
onClose* | (event: MouseEvent | KeyboardEvent) => void | Called when clicking outside the popover or when pressing the ESC key |
disableCloseOnBackdropClick | boolean | If `true`, clicking on the backdrop will not fire the `onClose` callback |
disableCloseOnEsc | boolean | If `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. |