# @nature-ui/portal

> React component used to render children outside the DOM hierarchy of the parent component

Latest version **2.2.13** (published 2023-04-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install @nature-ui/portal
pnpm add @nature-ui/portal
yarn add @nature-ui/portal
bun add @nature-ui/portal
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.13 |
| Published | 2023-04-12 |
| First published | 2020-12-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 27.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Divine Hycenth |
| Maintainers | dnature |
| Keywords | react, portal, nested portal, z-index, layer, nature ui |

## Links

- npm: https://www.npmjs.com/package/@nature-ui/portal
- Repository: https://github.com/DNature/nature-ui
- Issues: https://github.com/DNature/nature-ui/issues
- npm.io page: https://npm.io/package/@nature-ui/portal

## Dependencies (2)

- [@nature-ui/hooks](https://npm.io/package/@nature-ui/hooks.md) 2.2.13
- [@nature-ui/react-utils](https://npm.io/package/@nature-ui/react-utils.md) 2.2.13

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 2.2.13 (latest) — 2023-04-12
- 0.0.0-dev-20230411071731 (dev) — 2023-04-11
- 1.1.2 (next) — 2022-07-29
- 2.2.12 — 2023-04-12
- 2.2.11 — 2023-04-12
- 0.0.1 — 2023-04-11
- 0.0.0 — 2023-04-11
- 0.0.0-dev-20230410162901 — 2023-04-10
- 0.0.0-dev-20230410131720 — 2023-04-10
- 0.0.0-dev-20230409203337 — 2023-04-09
- 0.0.0-dev-20230409203113 — 2023-04-09
- 0.0.0-dev-20230409201910 — 2023-04-09
- 4.0.1 — 2023-04-09
- 4.0.0 — 2023-03-01
- 0.0.0-dev-20230301133840 — 2023-03-01
- … 25 more at https://npm.io/package/@nature-ui/portal/versions

## README

# Portal

A wrapper for rendering components in React Portals, with support for nested
portals and stacking. No need to use `z-index` at all with this portal, that's
right!

## Installation

```sh
yarn add @nature-ui/portal

# or

npm i @nature-ui/portal
```

## Import components

```jsx
import { Portal, PortalManager } from '@nature-ui/portal';
```

Render the `PortalManager` once at the root of your application

```jsx
function App() {
  return (
    <>
      <CSSReset />
      <PortalManager>{/* Your app goes here  */}</PortalManager>
    </>
  );
}
```

### Basic usage

Portals are render into the portal manager's node by default not
`document.body`.

> It'll only render into `document.body` if you don't include `PortalManager`.

```jsx
<div>
  <p>Welcome</p>
  <Portal>This text has been portaled</Portal>
</div>
```

### Nested portals

Nesting portal can be very useful to build complex widgets like nested menu,
popovers, modal, etc.

```jsx
<Portal>
  This is a portal.
  <Portal>This is a nested portal</Portal>
</Portal>
```

---
_Source: https://npm.io/package/@nature-ui/portal · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
