Package Exports
- lxw-react-popup
- lxw-react-popup/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (lxw-react-popup) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Welcome to lxw-react-popup 👋
🏠 Homepage
React Component based on ReactDOM.createPortal function for transportation element.
React + TypeScript 从零开发 Popup 组件并发布到 npm
Install
yarn add lxw-react-popup
# or
npm i lxw-react-popupUsage
import React, { useState } from 'react';
import { Popup } from 'lxw-react-popup';
import 'lxw-react-popup/dist/react-popup.min.css';
export default () => {
const [visible, setVisible] = useState(false);
return (
<>
<button onClick={() => setVisible(true)}>click me</button>
<Popup maskClosable visible={visible} onClose={() => setVisible(false)}>
<div className="your-content">hello world</div>
</Popup>
</>
);
};API
| Property | Description | Type | Default |
|---|---|---|---|
| visible | Optional,control content visibility | boolean | false |
| position | Optional,determines where the content will pop up | 'center' / 'top' / 'bottom' / 'left' / 'right' | 'center' |
| mask | Optional,decide whether to display the background layer | boolean | true |
| maskClosable | Optional,if the value is true, clicking on the background layer will trigger onClose function | boolean | false |
| onClose | Optional,a function to set the visible to false | function | ()=>{} |
| node | Optional,the mounted node | HTMLElement | - |
| destroyOnClose | Optional,whether content nodes are unloaded when closed | boolean | false |
| wrapClassName | Optional,className for the container node | string | '' |
Contributions Welcome!
git clone git@github.com:lvxiaowu/react-popup.git
cd react-popup
yarn
yarn startopen another terminal tab
cd example
yarn
yarn startRun tests
yarn testAuthor
👤 lvxiaowu
Show your support
Give a ⭐️ if this project helped you!
This README was generated with ❤️ by readme-md-generator