Skip to main content

Component <MainModal />

Props

PropsTypeMeaningPossible values
verticalPositionstringChange modal vertical position on the screentop / center
shapestringChange modal corners radiusrounded / squared
maxWidthstring / numberChange modal max widthfrom 0 to any number or string with units
fullWidthbooleanSet modal width to full width but limited by maxWidth proptrue / false
headernodeAdd modal header sectionelement
footernodeAdd modal footer sectionelement
hideCloseActionsbooleanRemove ability to close the modal by x-mark or bg clickstrue / false
isOpenbooleanSet modal statustrue / false
handleClosefunctionActions, after modal x-mark was clicked() => void



Positions

const MainModalPosition = ({ verticalPosition }) => {
const [isModal, setModal] = useState(false)

return (
<>
<button type="button" onClick={() => setModal(true)}>
Modal {verticalPosition}
</button>

<MainModal
verticalPosition={verticalPosition}
isOpen={isModal}
handleClose={() => setModal(false)}
>
Hello my dear friend!
</MainModal>
</>
)
}



Shape

const MainModalShape = ({ shape }) => {
const [isModal, setModal] = useState(false)

return (
<>
<button type="button" onClick={() => setModal(true)}>
Modal {shape}
</button>

<MainModal shape={shape} isOpen={isModal} handleClose={() => setModal(false)}>
Hello my dear friend!
</MainModal>
</>
)
}



Sizes

const MainModalSize = ({ maxWidth }) => {
const [isModal, setModal] = useState(false)

return (
<>
<button type="button" onClick={() => setModal(true)}>
{maxWidth}px width modal
</button>

<MainModal maxWidth={maxWidth} isOpen={isModal} handleClose={() => setModal(false)} fullWidth>
Hello my dear friend!
</MainModal>
</>
)
}



const MainMoadlHeaderFooter = ({ header, footer }) => {
const [isModal, setModal] = useState(false)

return (
<>
<button type="button" onClick={() => setModal(true)}>
Header Modal
</button>

<MainModal
header={header}
footer={footer}
isOpen={isModal}
handleClose={() => setModal(false)}
>
Hello my dear friend!
</MainModal>
</>
)
}



Closing actions control

const MainMoadlHeaderFooter = ({ hideActions }) => {
const [isModal, setModal] = useState(false)

return (
<>
<button type="button" onClick={() => setModal(true)}>
{hideActions ? 'With' : 'Without'} hide actions Modal
</button>

<MainModal isOpen={isModal} hideCloseActions={hideActions}>
<button type="button" onClick={() => setModal(false)}>
Close Modal
</button>
</MainModal>
</>
)
}