--- title: Multiple Teleports to Same Target Append in Order impact: LOW impactDescription: When multiple Teleport components target the same element, they append in declaration order type: capability tags: [vue3, teleport, modal, order] --- # Multiple Teleports to Same Target Append in Order **Impact: LOW** - Multiple `` components can mount content to the same target element. Content appends in declaration order - later teleports appear after earlier ones in the DOM. This is useful for notification stacks, modal layering, and tooltip systems. ## Task Checklist - [ ] Use consistent teleport targets for related UI (e.g., all modals to `#modals`) - [ ] Leverage natural stacking order or use z-index for layer control - [ ] Consider a notification/modal management system for complex cases **Basic Example:** ```vue ``` **Resulting DOM:** ```html
First notification
Second notification
``` ## Practical Example: Notification Stack ```vue ``` ## Modal Layering When modals open other modals, they naturally stack: ```vue ``` ## Controlling Order with z-index For explicit control over stacking: ```vue ``` ## Cross-Component Teleports Components from different parts of the app can teleport to the same target: ```vue ``` ## Reference - [Vue.js Teleport - Multiple Teleports on Same Target](https://vuejs.org/guide/built-ins/teleport.html#multiple-teleports-on-the-same-target)