Skip to content

Portal

Overview

Portal renders content into a DOM node that exists outside the parent component’s DOM hierarchy. Useful for overlays, modals, tooltips, and toasts that need to break out of overflow or stacking context constraints.

Usage

import { createPortal } from "@paramanu/utilities-js"
const portal = createPortal({ target: "#modal-root" })
portal.mount(myDialogElement)
// Later: portal.destroy()

Guidelines

  • Use portals to escape overflow hidden or stacking context issues
  • Set disabled to render in-place for SSR or testing
  • The portal container gets a data-pm-portal attribute for identification
  • Default target is document.body

API

PropTypeDefaultDescription
targetstring | HTMLElement"body"Target element or selector
disabledbooleanfalseRenders in-place without portalling