Socket
Socket
Sign inDemoInstall

@chakra-ui/portal

Package Overview
Dependencies
4
Maintainers
2
Versions
320
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @chakra-ui/portal

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


Version published
Weekly downloads
559K
increased by3.54%
Maintainers
2
Install size
64.8 kB
Created
Weekly downloads
 

Readme

Source

@chakra-ui/portal

A wrapper for rendering components in React Portals, with support for nested portals and stacking.

Installation

yarn add @chakra-ui/portal

# or

npm i @chakra-ui/portal

Import components

import { Portal, PortalManager } from "@chakra-ui/portal"

Render the PortalManager once at the root of your application

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.

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

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

<>
  <div ref={ref} />
  <Portal containerRef={ref}>
    <h1>Hello world</h1>
  </Portal>
</>

Keywords

FAQs

Last updated on 18 Jul 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc