--- title: Portal description: "`Portal` is a component that renders elements outside of the current `DOM` hierarchy." links: - source: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/portal --- # Portal `Portal` is a component that renders elements outside of the current `DOM` hierarchy. ```tsx <> 元の世界 ナツキ・スバル ``` ## Usage ```tsx import { Portal } from "@yamada-ui/react" ``` ```tsx import { Portal } from "@/components/ui" ``` ```tsx import { Portal } from "@workspaces/ui" ``` ```tsx ``` ### Change the destination To change the destination, set the `ref` of the destination to `containerRef`. By default, it transfers to the end of `document.body`. ```tsx const containerRef = useRef(null) return ( 元の世界 ナツキ・スバル エミリアたん ) ``` ### Disable portaling To disable forwarding, set `disabled` to `true`. ```tsx <> 元の世界 ナツキ・スバル ``` ## Props | Prop | Default | Type | Description | | -------------- | ------- | -------------------------------- | ---------------------------------------------------------------- | | `containerRef` | - | `RefObject` | The `ref` to the component where the portal will be attached to. | | `disabled` | - | `boolean` | If `true`, the forwarding will be disabled. | ## Similar Components - [For](https://yamada-ui.com/docs/components/for.md): `For` is a component used to loop over an array and render a component for each item. - [Format](https://yamada-ui.com/docs/components/format.md): `Format` is used to format dates, numbers, and bytes according to a specific locale. - [Slot](https://yamada-ui.com/docs/components/slot.md): `Slot` is a component that merges its props onto its immediate child. - [ClientOnly](https://yamada-ui.com/docs/components/client-only.md): `ClientOnly` is a component that renders its children only on the client side. - [Show](https://yamada-ui.com/docs/components/show.md): `Show` is a component that shows or hides its children based on a condition. ## Used By Components & Hooks - [ActionBar](https://yamada-ui.com/docs/components/action-bar.md): `ActionBar` is a component that is used to display a bottom action bar with a set of actions. - [Drawer](https://yamada-ui.com/docs/components/drawer.md): `Drawer` is a component for a panel that appears from the edge of the screen. - [Dropzone](https://yamada-ui.com/docs/components/dropzone.md): `Dropzone` is a component used for uploading files via drag and drop. - [FileButton](https://yamada-ui.com/docs/components/file-button.md): `FileButton` is a button component used for users to select files. - [FileInput](https://yamada-ui.com/docs/components/file-input.md): `FileInput` is a component used for users to select files. - [Loading](https://yamada-ui.com/docs/components/loading.md): `Loading` is a component displayed during waiting times, such as when data is being loaded. - [Modal](https://yamada-ui.com/docs/components/modal.md): `Modal` is a component that is displayed over the main content to focus the user's attention solely on the information. - [Popover](https://yamada-ui.com/docs/components/popover.md): `Popover` is a component that floats around an element to display information. - [Toggle](https://yamada-ui.com/docs/components/toggle.md): `Toggle` is a component that has two states: on or off. - [Tooltip](https://yamada-ui.com/docs/components/tooltip.md): `Tooltip` is a component that displays short information, such as supplementary details for an element.