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

https://github.com/victorbadaro/react-modal-portal-example

An example of how to create a modal using portals
https://github.com/victorbadaro/react-modal-portal-example

css css-grid css3 html html-css html-css-javascript html5 portal portals react reactjs typescript typescript-react vite vitejs

Last synced: 2 months ago
JSON representation

An example of how to create a modal using portals

Awesome Lists containing this project

README

          

# react-modal-portal-example

[![LEIAME.md](https://img.shields.io/badge/-Leia%20em%20Portugu%C3%AAs-brightgreen?style=for-the-badge)](./LEIAME.md)

Click [here](https://react-modal-portal-example.netlify.app/) to access the demo website πŸ™‚

## Summary
- [🧾 About](#-about)
- [πŸš€ Main technologies](#-main-technologies)
- [πŸ’» Usage](#-usage)

## 🧾 About
This is just an example of how to use portals to render a modal in React.

You'll see the DOM like this (before rendering the modal):

![image](https://github.com/victorbadaro/react-modal-portal-example/assets/9096344/db7a0552-6dab-4f00-81e9-55f688504356)

...and then (after rendering the modal):

![image](https://github.com/victorbadaro/react-modal-portal-example/assets/9096344/d7f38153-e5d4-4297-b69a-742d483f9e4d)

## πŸš€ Main technologies
- [React](https://react.dev/)
- [Typescript](https://www.typescriptlang.org/)
- [React Icons](https://react-icons.github.io/react-icons/)

_(You can see all the dependencies in the [package.json](./package.json) file)_

## πŸ’» Usage
1. Clone the project (you'll need a [personal access token](https://docs.github.com/pt/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls)):
```bash
$ git clone https://github.com/victorbadaro/react-modal-portal-example
```

2. Access its directory:
```bash
$ cd react-modal-portal-example
```

3. Install its dependencies:
```bash
$ yarn
# feel free to use another package manager, but you might want use yarn once there's already a yarn.lock file in the root directory
```

4. Start the server by running the `dev` script:
```bash
$ yarn dev
```
---

This project was created and developed with ❀ by Victor Badaró