Modals provide a means to render content in front of everything else on a page.
The modal module in BBUI exposes two
separate components to provide this functionality; a Modal
component to control visibility of content,
and a ModalContent
component to quickly construct the typical content - although this is optional.
One of the common problems with modals and popups is stale state reappearing after hiding and showing the content
again, since the state hasn't been garbage collected if a component controls its own visibility. This is handled for
you when using the Modal
component as it will fully unmount child components, properly resetting state
every time it appears.
Use ModalContent to render typical modal content.
Width can be specified as a prop to a Modal
. Any additional ModalContent
props provided
will be passed to the confirmation button.
Any content can be rendered inside a Modal
. Use context to close the modal from your own components.
Async functions passed in as the onConfirm prop will make the modal wait until the callback is completed.
Returning false from a onConfirm callback will prevent the modal being closed.