@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) • 989 B
JavaScript
'use client';
import * as React from 'react';
import { useTooltipRootContext } from "../root/TooltipRootContext.js";
import { TooltipPortalContext } from "./TooltipPortalContext.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 Tooltip](https://base-ui.com/react/components/tooltip)
*/
export function TooltipPortal(props) {
const {
children,
keepMounted = false,
container
} = props;
const {
mounted
} = useTooltipRootContext();
const shouldRender = mounted || keepMounted;
if (!shouldRender) {
return null;
}
return /*#__PURE__*/_jsx(TooltipPortalContext.Provider, {
value: keepMounted,
children: /*#__PURE__*/_jsx(FloatingPortalLite, {
root: container,
children: children
})
});
}