Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/surinderlohat/react-dialog

Easy can and clean way to show dialogs in react application
https://github.com/surinderlohat/react-dialog

Last synced: about 1 month ago
JSON representation

Easy can and clean way to show dialogs in react application

Awesome Lists containing this project

README

        

# React Dialog

Show Dialogs with easy way in react JS, super easy to use and can handel all the major user cases.
##### Based on the React hooks and reactive programing.
#### No extra dependencies pure react js code & lightweight.

## Features
1. useDialog Hook to show dialogs in functional components.
3. use dialog from any UI library i.e MUI/bootstrap or any other UI library
2. Open source Free to use.

## Installation
```sh
npm install @surinderlohat/react-dialog
or
yarn add @surinderlohat/react-dialog
```
## How to use
- Add Dialog Provider
App.tsx
```sh
import { FC } from 'react';
import { DialogProvider } from '@surinderlohat/react-dialog';
import BootstrapDialog from './BootstrapDialog';
import MUIDialog from './MUIDialog';

// App.tsx
const App: FC = () => {
return (




);
};

export default App;
```
- Import Use Dialog Hook that's it
#### MUI Dialog Example :
```sh
import { FC } from 'react';
import { Box, Button, Dialog, DialogTitle } from '@mui/material';
import { useDialog } from '@surinderlohat/react-dialog';

const MuiDialog: FC = () => {
const dialog = useDialog();

// Show MUI Dialog
const showMuiDialog = () => {
dialog.openDialog(
dialog.closeDialog()}>
MUI Dialog Example

Welcome to react dialog



);
};

return (

SHOW MUI DIALOG

);
};
export default MuiDialog;
```
#### Bootstrap Dialog Example :
```sh
import { FC } from 'react';
import { useDialog } from '@surinderlohat/react-dialog';
import { Modal, Button } from 'react-bootstrap';
import 'bootstrap/dist/css/bootstrap.min.css';

const BootstrapDialog: FC = () => {
const dialog = useDialog();

// Show Bootstrap Dialog
const showBootstrapDialog = () => {
dialog.openDialog(


Bootstrap Dialog Example


Modal body text goes here.




dialog.closeDialog()}>
Close

Save changes


);
};

return (


Show Dialog

);
};

export default BootstrapDialog;
```
## License
MIT **Free Software!**