[]previous and next page

Portals

createPortal(children, node) becomes <Portal mount={node}>.

For agentsUpdated

createPortal(children, node) becomes <Portal mount={node}>. The prop is mount, not container. It defaults to document.body. Nothing is left at the call site (no wrapper element, no comment), and nothing renders on the server. useShadow puts the content in a shadow root of the mount.

src/modal.tsxtsx
import { Portal } from "@shadow-js/web";

export function Modal(props: { target: HTMLElement }) {
  return (
    <section>
      <Portal mount={props.target}>
        <dialog open>Hello</dialog>
      </Portal>
    </section>
  );
}