1.0.7 • Published 7 months ago

vz-react-modal v1.0.7

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

vz-react-modal

This package is meant to be used for educational purpose. It is not intended to be maintained and could be deleted in the future.

React React DOM Documentation MIT licensed

About

A lightweight React modal component based on the HTML dialog element.

Install

# npm
npm install -D vz-react-modal

# yarn
yarn add -D vz-react-modal

# pnpm
pnpm add -D vz-react-modal

Usage

import { useState } from "react";
// Import the Modal component
import Modal from "vz-react-modal";

export default function App() {
  // Define state to track whether the modal is open or not
  const [isOpen, setIsOpen] = useState(false);

  // Add function to handle the close event of the modal
  const handleClose = () => {
    setIsOpen(false);
  };

  // Add function to handle the open event of the modal
  const handleClick = () => {
    setIsOpen(true);
  };

  return (
    <div
      style={{
        margin: "0 auto",
        textAlign: "center",
        minHeight: "100vh",
        padding: "1rem",
      }}>
      <p style={{ fontSize: "2rem", color: "#333", margin: "auto" }}>vz-react-modal</p>
      <button
        style={{
          backgroundColor: "#0074E4",
          padding: "0.5rem 1rem",
          fontWeight: "bold",
          color: "#fff",
          cursor: "pointer",
          borderRadius: "0.25rem",
          marginTop: "1rem",
        }}
        onClick={handleClick}>
        Open Modal
      </button>
      {/* Pass the props to the Modal component */}
      <Modal
        modalTitle="Modal title"
        modalMessage="Modal message"
        modalType="basic"
        isOpen={isOpen}
        handleClose={handleClose}
      />
    </div>
  );
}

Props

The vz-react-modal component accepts the following props:

NameTypeDescription
modalTitlestringThe title of the modal
modalMessagestringThe message to be displayed in the modal
modalTypestringThe type of the modal (allowed values : "basic", "info", "success", "warning", "error")
isOpenbooleanA boolean indicating whether the modal is open or not
handleClosefunctionA function to handle the close event of the modal

Examples

You can find below examples of the different modal types :

TypeExample
BasicBasic
InfoInfo
SuccessSuccess
WarningWarning
ErrorError

Styling

The vz-react-modal component is styled with Tailwind CSS.

License

MIT © Vinodh Zamboulingame

1.0.7

7 months ago

1.0.6

7 months ago

1.0.5

7 months ago

1.0.4

7 months ago

1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago