@alex-pqn/react-modal
v1.0.8
Published
[![NPM](https://img.shields.io/npm/l/@alex-pqn/react-modal)](LICENSE.md) [![npm](https://img.shields.io/npm/v/@alex-pqn/react-modal)](https://www.npmjs.com/package/@alex-pqn/react-modal) [![GitHub package.json version](https://img.shields.io/github/pack
Downloads
1
Readme
@alex-pqn/react-modal
Prerequisites
- You will need to have Node and
npm
installed locally on your machine.
| Node Version | Supported | | ------------ | ------------------ | | 16.x & > | :x: | | 15.x | :white_check_mark: |
Install
npm i @alex-pqn/react-modal
Example
Usage
import React, { useState } from 'react';
import { Modal } from '@alex-pqn/react-modal';
const App = () => {
const [isModalShown, setIsModalShown] = useState(false);
const openModal = () => setIsModalShown(true);
return (
<main>
<button onClick={openModal}>Open modal</button>
<Modal
isShown={isModalShown}
trigger={setIsModalShown}
width={27}
title="Your modal title"
message="Your modal message"
/>
</main>
);
};
export default App;
Props
| Name | Description | Type | Is Required | Default | | ------- | ----------------------------------- | ------------------ | ----------- | ------------------ | | isShown | Is modal shown ? | boolean | Yes | n/a | | trigger | A trigger for turning off the modal | func | Yes | n/a | | width | The modal width | number 1-100 | No | 27 | | title | Your modal title | string | No | Your modal title | | message | Your modal message (can be DOM) | n/a | No | Your modal message |