Skip to content

Repository files navigation

Portal

Lightweight DOM portal (teleport) utility with fully focus management. Designed for accessible dialogs, menus, overlays, popovers.

Install

npm i @y14e/portal
// npm
import { createPortal } from '@y14e/portal';

// CDNs
import { createPortal } from 'https://esm.sh/@y14e/portal@1.3.0';
// or
import { createPortal } from 'https://cdn.jsdelivr.net/npm/@y14e/portal@1.3.0/+esm';
// or
import { createPortal } from 'https://esm.unpkg.com/@y14e/portal@1.3.0';

📦 APIs

createPortal

Creates a portal and preserves keyboard focus order between the original DOM and the portal.

const cleanup = createPortal(host, container, options);
// => () => void
//
// host: Element
// container (optional): Element (default: <body>)
// options (optional): PortalOptions

🪄 Options

interface PortalOptions {
  noInlineStyle: boolean; // default: false
}

Demo

https://y14e.github.io/portal/

About

Lightweight DOM portal (teleport) utility with fully focus management. Designed for accessible dialogs, menus, overlays, popovers.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages