A <slot> marks where content passed between the component's tags appears.
- Default slot:
<slot></slot> - Named slots:
<slot name="footer">, filled with<template #footer> - Fallback content goes inside the slot tag.
Pass content into a component.
✍️ 3 exercises + code challenge in this lessonA <slot> marks where content passed between the component's tags appears.
<slot></slot><slot name="footer">, filled with <template #footer>Mastering Vue Slots helps you write clean and reliable Vue.js code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.
<script src="https://unpkg.com/vue@3.5.12/dist/vue.global.prod.js"></script>
<div id="app">
<panel>
<p>This content goes into the default slot.</p>
<template #footer>Footer text</template>
</panel>
</div>
<script>
const app = Vue.createApp({});
app.component("panel", {
template: `<section style="border:2px solid #42b883;border-radius:8px;padding:10px">
<slot>Nothing here</slot>
<footer style="color:#64748b"><slot name="footer"></slot></footer>
</section>`
});
app.mount("#app");
</script>
Check what you learned in “Vue Slots”.
Mark where passed-in content appears.
template: `<div class="box"><></></div>`
How do you fill a named slot called "footer"?
The card component ignores its content. Add a <slot> so "Inside card" appears in the .card div.
Free sign-in required · Google login available
Stuck on something?
Ask the community in the CodesInTech forum.
Need a developer?
Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.
Explore Our Services