Modal

The Modal is an interface component positioned over the page content to put emphasis on new elements. It blocks standard navigation, and requires an interaction from the user to be dismissed.

Installation

To install @igloo-ui/modal in your project, you will need to run the following command using npm:

npm install @igloo-ui/modal

If you prefer Yarn, use the following command instead:

yarn add @igloo-ui/modal

Usage

Then to use the component in your code just import it!

import Modal from '@igloo-ui/modal';
import Button from '@igloo-ui/button';

const [show, setShow] = useState(false);

<Button appearance="secondary" onClick={() => setShow(true)}>
  open modal
</Button>;

<Modal
  title={`Modal title`}
  isDismissable
  isClosable
  isOpen={show}
  closeBtnAriaLabel={`Close`}
  onClose={() => setShow(false)}
>
  Modal content
</Modal>;

API

PropTypeDescription
childrenReactNodeThe content to display inside the modal
classNamestringAdd a specific class to the modal
dataTeststringAdd a data-test tag for automated tests
sizeSizeChanges the modal width
titlestringThe content for the title of the modal
isClosablebooleanRender the close button
isOpenbooleanWhether the modal is open or not
isDismissablebooleanWhether to close the overlay when the user interacts outside it.
onClose() => voidHandler that is called when the overlay should close.
onAfterClose() => voidHandler that is called when the modal is closed and no longer visible.
closeBtnAriaLabelstringThe content for the aria-label on the close button
fullContentbooleanRemove the default padding and the title from the modal