2022-10-06 09:15:30 +00:00
---
description: The < Teleport > component teleports a component to a different location in the DOM.
---
2022-09-13 12:54:31 +00:00
# `<Teleport>`
2022-04-01 14:06:48 +00:00
2022-10-06 09:15:30 +00:00
The `<Teleport>` component teleports a component to a different location in the DOM.
2022-04-01 14:06:48 +00:00
2022-10-06 09:15:30 +00:00
The `to` target of [`<Teleport>` ](https://vuejs.org/guide/built-ins/teleport.html ) expects a CSS selector string or an actual DOM node. Nuxt currently has SSR support for teleports to `body` only, with client-side support for other targets using a `<ClientOnly>` wrapper.
2022-04-01 14:06:48 +00:00
2022-08-13 07:27:04 +00:00
## Example: `body` Teleport
2022-04-01 14:06:48 +00:00
```vue
< template >
< button @click =" open = true" >
Open Modal
< / button >
< Teleport to = "body" >
< div v-if = "open" class = "modal" >
< p > Hello from the modal!< / p >
< button @click =" open = false" >
Close
< / button >
< / div >
< / Teleport >
< / template >
```
2022-08-13 07:27:04 +00:00
## Example: Client-side Teleport
2022-04-01 14:06:48 +00:00
```vue
2022-08-13 07:27:04 +00:00
< template >
2022-04-01 14:06:48 +00:00
< ClientOnly >
< Teleport to = "#some-selector" >
<!-- content -->
< / Teleport >
< / ClientOnly >
< / template >
```
2022-04-09 09:25:13 +00:00
:LinkExample{link="/examples/app/teleport"}