<template> Template Wrapper
Last updated: 2026-10-22
<template> Template Wrapper
is a transparent grouping wrapper — it renders nothing itself, useful for v-if/v-for groups and slot contents.
| Group | Built-ins |
|---|---|
| Kind | Component / Element |
| Scope | Template |
| Vue Version | 3.0+ |
| SSR Support | Yes |
📝 Syntax
<template v-if="ok">
<p>First</p>
<p>Second</p>
</template>
<template v-for="item in list" :key="item.id">...</template>
⚙️ Arguments
| props | Works with v-if, v-for and v-slot; renders no element itself |
|---|
▶ Example
Edit the code below and see the live result:
Output:
Both paragraphs toggle together without leaving an empty wrapper.
💡 Key Points
💡 Tip Wrap several elements under one v-if without adding a pointless div.
ℹ️ Note template also carries slot content with v-slot.
⚠️ Warning With v-for on a template, put the key on the template too.
🏷️ Related Built-ins
💡 Related Cases
More case studies coming soon.
📚 Related Tutorials
❓ FAQ
Q Does it appear in the DOM?
A No — it is a compile-time wrapper.
Q Can it carry a class?
A No — attributes need a real element.
Q Is it the same as slot templates?
A Same tag, two roles: grouping and slot carriers.