1.0.2 • Published 9 months ago

mui-react-modal v1.0.2

Weekly downloads
-
License
MIT License
Repository
github
Last release
9 months ago

mui-react-modal

Creating a Custom Modal and Dialog Component with MUI (Material-UI) in React for Enhanced User Experience.

Install

Using npm

npm i mui-react-modal

Using yarn

yarn add mui-react-modal

Basic Usage for modal

import React, { useState } from 'react';
import { Modal } from 'mui-react-modal';
import { Button } from '@mui/material';

export default function Test() {
    const [open, setOpen] = useState(false);

    const handleModal = () => setOpen(!open);

    const modalAction = <Button variant='outlined' size='small'>Save</Button>
    
    return (
        <>
            <Button onClick={handleModal}>Open Modal</Button>
            <Modal
                open={open}
                title={"Modal heading"}
                description={"Modal description."}
                close={handleModal}
                action={modalAction}
                actionPosition="right"
            />
        </>
    )
}

API & Supported parameters for modal

PropertyTypeDefaultRequiredDescription
openBooleanfalsetrueControls whether the modal is open or closed.
closeFunctionnullfalseA function to close the modal.
titleString \|\| ElementnullfalseShow modal title.
descriptionString \|\| ElementnullfalseShow modal description.
actionElementnullfalseThe element to be used as the modal's action button(s).
closeIconBooleantruefalseDetermines whether the modal close icon is visible.
customStyleObjectObjectfalseA style object that allows customization of the modal's default style.
actionPositionStringleftfalseThe position of the action element(s) within the modal. Supported values are "left" "center"and"right".
modalRootClassStringnullfalseA CSS class name to modify the default style of the modal root.
closeIconRootClassStringnullfalseA CSS class name to modify the default style of the close icon.
titleRootClassStringnullfalseA CSS class name to modify the default style of the modal title.
descriptionRootClassStringnullfalseA CSS class name to modify the default style of the modal description.
actionRootClassStringnullfalseA CSS class name to modify the default style of the modal action element(s).
closeOnBackgroundCheckBooleantruefalseMake it false if you don't want to close modal on outside check or background check.

Basic Usage for dialog

import React, { useState } from 'react';
import { Dialog } from 'mui-react-modal';
import { Button } from '@mui/material';

export default function Test() {
    const [open, setOpen] = useState(false);

    const handleDialog = () => setOpen(!open);

    const dialogAction = <Button variant='outlined' size='small'>Save</Button>
    
    return (
        <>
            <Button onClick={handleDialog}>Open Dialog Box</Button>
            <Dialog
                open={open}
                title={"Dialog Box Heading"}
                description={"Dialog Box Description."}
                close={handleDialog}
                action={dialogAction}
                actionPosition="right"
            />
        </>
    )
}

API & Supported parameters for dialog

PropertyTypeDefaultRequiredDescription
openBooleanfalsetrueControls whether the dialog is open or closed.
closeFunctionnullfalseA function to close the dialog.
titleString \|\| ElementnullfalseShow dialog title.
descriptionString \|\| ElementnullfalseShow dialog description.
actionElementnullfalseThe element to be used as the dialog's action button(s).
dividersBooleanfalsefalseControls whether to show dividers between sections in the dialog.
closeIconBooleantruefalseControls whether to show a close icon in the dialog header.
hideBackdropStringfalsefalseControls whether to hide the backdrop when the dialog is open.
dialogTitleSxObject{}falseStyle object for the dialog title.
dialogContentSxObject{}falseStyle object for the dialog content.
dialogActionSxObject{}falseStyle object for the dialog actions.
dialogRootSxObject{}falseStyle object for the dialog root element.
closeIconSxObject{...}falseStyle object for the close icon.
fullScreenBooleanfalsefalseControls whether the dialog should be displayed in full-screen mode.

Upcoming Features

We are dedicated to continuously enhancing the library to provide an even better user experience.

Contributing

Contributions are welcome! If you have any ideas, suggestions, or bug fixes, feel free to open an issue or submit a pull request.

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

10 months ago

0.2.2

10 months ago

0.2.1

10 months ago

0.1.1

10 months ago

0.1.0

10 months ago

0.0.6

10 months ago

0.0.5

10 months ago

0.0.4

10 months ago

0.0.3

10 months ago

0.0.2

10 months ago

0.0.1

10 months ago