GithubHelp home page GithubHelp logo

thaind97git / pure-modal-react-portal Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 646 KB

A simple, pure, and accessible modal component for React with portal support.

Home Page: https://thaind97git.github.io/pure-modal-react-portal

License: MIT License

JavaScript 63.21% Shell 0.34% HTML 3.76% TypeScript 29.58% SCSS 3.11%
modal portal react

pure-modal-react-portal's Introduction

pure-modal-react-portal

Git issue Git forks Git star Git MIT

NPM

Simple modal component for ReactJS with Portal

  • Without dependencies
  • Support React Portal
  • Easy to custom style

Demo

https://thaind97git.github.io/pure-modal-react-portal

Installation

npm install --save pure-modal-react-portal

Usage

Jsx Component:

import React, { useState } from 'react';
import PureModal from 'pure-modal-react-portal';

const App = () => {
  const [open, setOpen] = useState(false);
  return (
    <div>
      <button onClick={() => setOpen(true)}>Open Modal</button>
      <PureModal
        prefixCls="custom-modal"
        open={open}
        onClose={() => setOpen(false)}
      >
        <div>Modal Content</div>
      </PureModal>
    </div>
  );
};
export default Modal;

Styling:

.custom-modal {
  &__close-element {
    display: block;
    width: 54px;
    height: 54px;
    line-height: 54px;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  &__wrapper-content {
    padding-bottom: 24px;
    top: 100px;
  }
  &__content {
    .header {
      padding: 16px 24px;
      border-bottom: 1px solid rgba(0, 0, 0, 0.06);
      border-radius: 2px 2px 0 0;
    }
    .body {
      padding: 24px;
    }
    .footer {
      padding: 10px 16px;
      border-top: 1px solid rgba(0, 0, 0, 0.06);
      border-radius: 0 0 2px 2px;
    }
  }
}

Props:

Name Type Default Description
open boolean false State to open/close modal
onClose void () => {} Close modal callback
destroyOnClose boolean false Unmount modal when closed
maskCloseable boolean true Close outside modal to close
zIndex number 1000 Z-index of modal
prefixCls string "" Prefix class modal to custom style
closeIcon JSX.Element or string null Custom close modal icon
header JSX.Element or string null Header section
footer JSX.Element or string null Footer section
children JSX.Element or string Modal children

pure-modal-react-portal's People

Contributors

thaind97git avatar

Watchers

 avatar  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.