About
A utility component that renders its children into document.body (or a custom container) instead of their parent's DOM position, so overlays like tooltips and popovers escape clipping ancestors with overflow:hidden or low stacking contexts.
Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Portal to your project and fits it to your theme.
Code
How Portal is used: the demo's code. The component's own source comes with a free account.
Usage.tsx
"use client";
import { Portal } from "@/components/ui/portal";
import * as React from "react";
export default function PortalDemo() {
const [open, setOpen] = React.useState(true);
return (
<div className="flex w-full flex-col items-center gap-6 p-10">
<div className="w-full max-w-md rounded-xl border border-border bg-card p-5 shadow-sm">
<p className="mb-3 text-sm font-medium text-muted-foreground">
Render into document.body
</p>
<div className="relative overflow-hidden rounded-lg border border-dashed border-border bg-muted/40 p-4">
<p className="text-sm font-medium text-foreground">
This box has{" "}
<code className="rounded bg-muted px-1 py-0.5 text-xs">
overflow: hidden
</code>
</p>
<p className="mt-2 text-sm text-muted-foreground">
Anything rendered here normally would be clipped at its edge. The
panel below is rendered through a Portal, so it escapes.
</p>
{open && (
<Portal>
<div className="fixed bottom-6 right-6 z-50 w-64 rounded-lg border border-border bg-popover p-4 text-sm text-popover-foreground shadow-lg">
I'm mounted on <code>document.body</code>, not inside the
box above.
</div>
</Portal>
)}
</div>
</div>
<button
type="button"
onClick={() => setOpen((v) => !v)}
className="rounded-md border border-border bg-background px-3 py-1.5 text-sm font-medium text-foreground hover:bg-muted"
>
{open ? "Hide portal panel" : "Show portal panel"}
</button>
</div>
);
}








