# @teste-ui/portal

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

Latest version **2.0.4** (published 2022-07-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install @teste-ui/portal
pnpm add @teste-ui/portal
yarn add @teste-ui/portal
bun add @teste-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.0.4 |
| Published | 2022-07-14 |
| First published | 2022-07-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 48.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Segun Adebayo |
| Maintainers | benits |
| Keywords | react, portal, nested portal, z-index, layer, chakra ui |

## Links

- npm: https://www.npmjs.com/package/@teste-ui/portal
- Repository: https://github.com/teste-ui/teste-ui
- Homepage: https://github.com/teste-ui/teste-ui#readme
- Issues: https://github.com/teste-ui/teste-ui/issues
- npm.io page: https://npm.io/package/@teste-ui/portal

## Dependencies (3)

- [@teste-ui/hooks](https://npm.io/package/@teste-ui/hooks.md) 2.0.4
- [@teste-ui/utils](https://npm.io/package/@teste-ui/utils.md) 2.0.4
- [@teste-ui/react-utils](https://npm.io/package/@teste-ui/react-utils.md) 2.0.1

## 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.0.4 (latest) — 2022-07-14
- 2.0.3 — 2022-07-13

## README

# @teste-ui/portal

A wrapper for rendering components in React Portals, with support for nested
portals and stacking.

## Installation

```sh
yarn add @teste-ui/portal

# or

npm i @teste-ui/portal
```

## Import components

```jsx
import { Portal, PortalManager } from "@teste-ui/portal"
```

Render the `PortalManager` once at the root of your application

```jsx
function App() {
  return (
    <ThemeProvider>
      <CSSReset />
      <PortalManager>{/* Your app goes here  */}</PortalManager>
    </ThemeProvider>
  )
}
```

### Basic usage

Portals are render into the portal manager's node by default not
`document.body`.

```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>
```

### Custom container

You can also portal elements into a custom containers. Simply pass a
`containerRef` prop that points to the `node` of that element.

```jsx
<>
  <div ref={ref} />
  <Portal containerRef={ref}>
    <h1>Hello world</h1>
  </Portal>
</>
```

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