Code Monkey home page Code Monkey logo

react-modal's Introduction

React Modal

Overview

This project provides a simple and lightweight solution for displaying modal dialogs in React using portals. The implementation utilizes React portals to render modals outside the normal DOM hierarchy, allowing for better control and flexibility over their styling and behavior.

Features

  1. Confirm Dialog Modal: A modal for displaying confirmation dialogs with options to confirm or cancel an action.

  2. Alert Modal: A modal for displaying informational alerts with a single "OK" button.

  3. Loading Modal: A modal for indicating that a process is in progress, preventing user interaction until the loading is complete.

  4. Portal Rendering: All modals are rendered using React portals, enabling independent styling and positioning.

Getting Started

Installation

To use this modal component in your React project, clone or download the project repository. Copy the modal directory into your project and import the modal components as needed and also styles.css.

Usage

Import the modal components in your React component file:

import { ModalLoading, ConfirmDialog, AlertDialog } from './modal';

function MyComponent() {
  return (
    <div>
      {/* Your other components and content */}

      {/* Example usage of Confirm Dialog Modal */}
      <ConfirmDialog
        open={/* boolean indicating whether the modal is open */}
        title={/* Title of the modal */}
        leftBtnClick={/* callback function for left btn action */}
        rightBtnClick={/* callback function for right btn action */}
      >
        {/* Content of the modal */}
      </ConfirmDialog>

      {/* Example usage of Alert Modal */}
      <AlertDialog
        open={/* boolean indicating whether the alert modal is open */}
        onClose={/* callback function for handling alert close action */}
        title={/* Title of the modal */}
        bodyText={/* Description of the modal */}
      />

      {/* Example usage of Loading Modal */}
      <ModalLoading
        show={/* boolean indicating whether the loading modal is open */}
      />

      {/* Your other components and content */}
    </div>
  );
}

Styling

Customize the styles of the modals by applying your own CSS directly to the modal components or by using inline styles. The modals are designed to be easily styled to match the look and feel of your application.

Contributing

If you encounter any issues or have suggestions for improvements, please open an issue on the GitHub repository. Contributions are welcome!

react-modal's People

Contributors

dev-zha avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.