0.1.8 • Published 2 years ago

@ousshmi/react-modal v0.1.8

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

A React modal npm package

Install

Using npm:

$npm install @ousshmi/react-modal

Using yarn:

$yarn add @ousshmi/react-modal

Usage

In a React app, import and use the Modal components:

import Modal from '@ousshmi/react-modal'

Modal props

NameTypeDescription
showbooleanShow/Hide the modal
onClosefunctionUse this function to set show value to 'false' and close the modal
titlestringCustomize the title of the modal
messagestringCustomize the message of the modal
closeButtonbooleanShow/Hide the close button
closeIconstringA path to a close icon you want to use when 'closeButton = {false}'
addNewButtonbooleanShow/Hide a new button, If 'true' a new button will be added
newButtonTextstringWhen 'addNewButton={true}' you could customize the text of the new button
onClickNewButtonfunctionUse this function to do whatever you want after clicking on the new button

Modal style props

NameTypeDescription
wrapperBackgroundstringA normal CSS values
marginstringA normal CSS values
widthstringA normal CSS values
maxWidthstringA normal CSS values
borderstringA normal CSS values
borderRadiusstringCustomize CSS values and use (overFlow : "hidden") to see result
overflowstringA normal CSS values
headerBackgroundstringA normal CSS values
headerPaddingstringA normal CSS values
headerFontstringEverything about the font, example values: "bold 15px roboto"
headertextColorstringA normal CSS values
bodyBackgroundstringA normal CSS values
bodyPaddingstringA normal CSS values
bodyFontstringEverything about the font, example values: "bold 15px roboto"
bodytextColorstringA normal CSS values
bodyBorderTopstringA normal CSS values
bodyBorderBottomstringA normal CSS values
footerPaddingstringA normal CSS values
footerBackgroundstringA normal CSS values
buttonPaddingstringA normal CSS values
buttonBackgroundstringA normal CSS values
buttonBorderstringA normal CSS values
buttonBorderRadiusstringA normal CSS values
buttonFontstringEverything about the font, example values: "bold 15px roboto"
buttonTextColorstringA normal CSS values
buttonMarginstringA normal CSS values

Example usage


import { useState } from "react";
import Modal from "./components/Modal";

function App() {
const [show, setShow] = useState(false);
return (
    <div>
        <button onClick={() => setShow(true)}>Open Modal</button>
        <Modal
            onClose={() => setShow(false)}
            show={show}
            message="The modal is opened!"
            closeButton={true}
            borderRadius="5px"
            overflow="hidden"
            headerBackground="gray"
            addNewButton
            newButtonText="Go to..."
        />
    </div>
);
}
export default App;