VueJS part 14: Scoped slots and conditional slot rendering

4 min readDec 3, 2023


Recently, I started learning VueJS, and this article is part of the series of my notes while learning it. In this post, I am covering two, bit more advanced topics of the slots. One of them is conditional slots. I called it conditional, but that is not the best way to call it. What I mean here is checking if the slot template is defined. The second one is scoped slots. Scoped slots are important because sometimes you want to pass some data to the slot. For that, you need to use scoped slots.

VueJS logo

Initial component

A great example we can use for scoped and conditional slots is a list. Lists are quite a common requirement in UI development. Depending on the use case, we would render different list items differently. Let’s start by defining this starter list component that will in its basic version just accept the list of items we want to render.

<li v-for="item in listItems" :key="">List item</li>

export default {
props: ["items"],
computed: {
listItems() {
return this.$props.items;
data() {
return {}

Items I am using in this example are quite simple, they contain the id, title, and description property. As I…