Skip to main content

Modal

Quick start

Here's a quick start guide to get started with the modal component

Importing Component

import { Modal } from "@hover-design/react";

Code Snippets and Examples

Simple Modal
import { Modal, Label, Input, Flex, Button } from "@hover-design/react";

function Demo() {
const [isOpen, setIsOpen] = useState(false);
<Button onClick={()=>{setIsOpen(true)}}>Open Modal</Button>
<Modal
title="Modal Title"
isOpen={isOpen}
onClose={() => {
setIsOpen(false);
}}
>
{/* Modal content */}
</Modal>;
}
<Modal isCloseIconVisible={false}>{/* Modal content */}</Modal>
<Modal showOverlay={false}>{/* Modal content */}</Modal>
Prevent Clicking Outside Modal to Close
<Modal closeOnClickOutside={false}>{/* Modal content */}</Modal>
Customizing Modal Base and overlay

You can customize the base and overlay styles of the modal by passing in the baseStyles and overlayStyles props. Refer this Spec for this:

overlayStyles

PropertyDescriptionDefault
backgroundColorBackground of Overlayrgba(0, 0, 0)
zIndexZ Index1
positionPositionfixed
topTop0
leftLeft0
rightRight0
bottomBottom0
filterFilterunset
opacityopacity0.5

baseStyles

PropertyDescriptionDefault
backgroundColorBackground of Basergba(255, 255, 255)
zIndexZ Index10
positionPositionrelative
transformTransformtranslate(-50%, -50%)
topTop50%
leftLeftunset
rightRightunset
bottomBottomunset
paddingPadding12px
widthWidth440px
heightheightauto
boxShadowBox Shadow0 0 10px rgba(0, 0, 0, 0.5)
<Modal baseStyles={{ backgroundColor: "#C1292E" }} isCloseIconVisible={false}>
{/* Modal content */}
</Modal>

Props Reference

KeytypeOptional?
childrenReact.ReactNodeNo
isOpenbooleanNo
onClose()=>voidNo
titlestringYes
closeOnClickOutsidebooleanYes
isCloseIconVisiblebooleanYes
baseStylesbase CSS objectYes
overlayStylesoverlay CSS objectYes
showOverlaybooleanYes