UNPKG

@base-ui-components/react

Version:

Base UI is a library of headless ('unstyled') React components and low-level hooks. You gain complete control over your app's CSS and accessibility features.

34 lines (33 loc) 1.02 kB
'use client'; import * as React from 'react'; import { usePreviewCardRootContext } from "../root/PreviewCardContext.js"; import { PreviewCardPortalContext } from "./PreviewCardPortalContext.js"; import { FloatingPortalLite } from "../../utils/FloatingPortalLite.js"; import { jsx as _jsx } from "react/jsx-runtime"; /** * A portal element that moves the popup to a different part of the DOM. * By default, the portal element is appended to `<body>`. * * Documentation: [Base UI Preview Card](https://base-ui.com/react/components/preview-card) */ export function PreviewCardPortal(props) { const { children, keepMounted = false, container } = props; const { mounted } = usePreviewCardRootContext(); const shouldRender = mounted || keepMounted; if (!shouldRender) { return null; } return /*#__PURE__*/_jsx(PreviewCardPortalContext.Provider, { value: keepMounted, children: /*#__PURE__*/_jsx(FloatingPortalLite, { root: container, children: children }) }); }