What is @radix-ui/react-portal?
The @radix-ui/react-portal package is a React component library that allows you to render components in a different part of the DOM than their parent components. This is particularly useful for rendering modals, tooltips, and other floating elements that need to break out of the normal document flow to avoid issues with overflow, z-index, and CSS inheritance.
Rendering children in a portal
This feature allows you to render a React component or any JSX outside of its parent component's DOM hierarchy. The code sample demonstrates how to use the Portal component to render a div element at the end of the document body.
{"import { Portal } from '@radix-ui/react-portal';\n\nconst MyComponent = () => (\n <Portal>\n <div>\n This will be rendered outside the parent DOM hierarchy.\n </div>\n </Portal>\n);"}