Scoped Slots: Passing Data to Parent
slot :data='value', v-slot='{ data }' on the parent side, render prop pattern.
Scoped Slots: Passing Data to Parent is a free Vue Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Vue Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
The Limitation of Plain Slots
Plain slots let a parent pass markup down, but the parent cannot access the child internal data. Scoped slots solve this by letting the child expose data back up to the slot content.
Binding Data on a Slot
The child binds attributes on its <slot> element, called slot props. These are passed to whatever the parent renders.
<!-- List.vue -->
<ul>
<li v-for="(item, i) in items" :key="item.id">
<slot :item="item" :index="i"></slot>
</li>
</ul>Receiving Slot Props
In the parent, the value of v-slot becomes an object containing all the slot props the child bound.
<List :items="users">
<template v-slot:default="slotProps">
{{ slotProps.index }}: {{ slotProps.item.name }}
</template>
</List>Destructuring Slot Props
Because the slot value is just an object, you can destructure it inline for cleaner code.
<List :items="users">
<template v-slot:default="{ item, index }">
{{ index }}: {{ item.name }}
</template>
</List>Shorthand for Default Scoped Slot
When you only use the default slot, you can put v-slot directly on the component tag instead of a nested template.
<List :items="users" v-slot="{ item }">
{{ item.name }}
</List>Renaming and Defaults
Destructuring supports renaming and default values, just like normal JavaScript.
<template v-slot:default="{ item: user, index = 0 }">
{{ index }} - {{ user.name }}
</template>Named Scoped Slots
Named slots can be scoped too. Combine the name with the destructured props.
<DataTable :rows="rows">
<template #cell="{ value, column }">
<strong>{{ column }}: {{ value }}</strong>
</template>
</DataTable>Renderless Components
Scoped slots enable the renderless component pattern: a component handles logic and state but renders no markup of its own - it just exposes data through a scoped slot and lets the parent decide the UI.
A Renderless Mouse Tracker
The component tracks the cursor and exposes coordinates. It renders only its default slot, passing x and y.
<!-- Mouse.vue setup -->
<slot :x="x" :y="y"></slot>Consuming the Renderless Component
The parent supplies all visuals and reads the exposed data, fully decoupling logic from presentation.
<Mouse v-slot="{ x, y }">
<p>Cursor is at {{ x }}, {{ y }}</p>
</Mouse>Scoped Slots vs Composables
Composables often replace renderless components in Vue 3 for pure logic reuse. But scoped slots still win when the child must control iteration or structure (like a list or table) while the parent customizes each item.
Quick Check
How does a parent receive data exposed by a scoped slot?
Recap
You learned scoped slots let a child expose data upward by binding props on its <slot>. The parent reads them through the v-slot value (often destructured), enabling renderless components that separate logic from presentation.
Frequently asked questions
Is the “Scoped Slots: Passing Data to Parent” lesson free?
Yes — the full text of “Scoped Slots: Passing Data to Parent” is free to read here on the web, and the Vue Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Vue Academy course, upgrade to CoddyKit PRO.
What will I learn in “Scoped Slots: Passing Data to Parent”?
slot :data='value', v-slot='{ data }' on the parent side, render prop pattern. You practise Vue Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Vue Academy?
No prior experience is required. Vue Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Scoped Slots: Passing Data to Parent” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Vue Academy lesson?
Yes. Every Vue Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Named Slots and Default Slot
- Scoped Slots: Passing Data to Parent
- Dynamic Slot Names
- Slot Fallback Content and Checking Slots