# @bianic-ui/portal

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

Latest version **0.1.0-alpha.2** (published 2020-09-03) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0-alpha.2 |
| Published | 2020-09-03 |
| First published | 2020-09-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 43.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Muhammad Rafiul Ilmi Syarifudin |
| Maintainers | ilmimris |
| Keywords | react, portal, nested portal, z-index, layer, bianic ui |

## Links

- npm: https://www.npmjs.com/package/@bianic-ui/portal
- Repository: https://gitlab.com/bia-design/bianic-ui
- Homepage: https://gitlab.com/bia-design/bianic-ui#readme
- Issues: https://gitlab.com/bia-design/bianic-ui/issues
- npm.io page: https://npm.io/package/@bianic-ui/portal

## Dependencies (2)

- [@bianic-ui/hooks](https://npm.io/package/@bianic-ui/hooks.md) ^0.1.0-alpha.2
- [@bianic-ui/utils](https://npm.io/package/@bianic-ui/utils.md) ^0.1.0-alpha.2

## 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

- 0.1.0-alpha.2 (latest) — 2020-09-03
- 0.1.0-alpha.1 — 2020-09-03

## README

# @bianic-ui/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 @bianic-ui/portal

# or

npm i @bianic-ui/portal
```

## Import components

```jsx
import { Portal, PortalManager } from "@bianic-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`.

> 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>
```

### Custom container

You can also portal elements into a custom containers. Simply pass a `container`
prop that points to the `node` of that element.

```jsx
<>
  <div data-testid="container" ref={ref} />
  <Portal container={() => ref.current}>
    <h1 data-testid="heading">Hello world</h1>
  </Portal>
</>
```

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