With props, events and v-model, a parent can pass data to a child and receive its notifications. But there is something it still cannot do: decide part of what the child renders. Think of an HTML <button>: it does not receive its text as an attribute, but as content between its tags, and that content can be text, an icon or both. Slots give your components that same ability: the child defines the structure and leaves gaps, and the parent fills them with its own markup. In this lesson you will learn about the default slot and its fallback content, named slots, who "sees" what inside a slot, scoped slots (which let the child pass data to the parent's content), conditional and dynamic slots, and when a prop is the better choice and when a slot is. In Colmena we will create BaseButton and BasePanel, give RoomCard an #actions slot and give RoomList a scoped slot for customising each room.

Contents

  1. What a slot is
  2. The default slot and fallback content
  3. Named slots
  4. Render scope: what a slot's content can see
  5. Scoped slots: the child passes data to the parent
  6. Conditional slots: $slots and useSlots
  7. Dynamic slot names
  8. Renderless components
  9. Props or slots?
  10. Case study: BaseButton, BasePanel and slots in the catalogue

  1. What a slot is

A slot is a gap in a component's template that the parent can fill with content. In the child it is marked with the <slot> element; in the parent, the content is written between the component's tags:

<!-- Child: ColmenaNotice.vue -->
<template>
  <div class="colmena-notice">
    <strong>Notice:</strong>
    <slot></slot> <!-- whatever the parent writes will go here -->
  </div>
</template>
<!-- Parent -->
<ColmenaNotice>
  The <em>Néctar Room</em> closes at 18:00 today.
</ColmenaNotice>

Result:

<div class="colmena-notice">
  <strong>Notice:</strong>
  The <em>Néctar Room</em> closes at 18:00 today.
</div>

The content can be anything that can be written in a template: text, HTML elements, other components, directives, interpolations.

flowchart LR
    subgraph Parent["Parent's template"]
        C["Content:<br/>The Néctar Room closes..."]
    end
    subgraph Child["Child's template"]
        E["div.colmena-notice"] --> S["strong: Notice"]
        E --> R["slot (gap)"]
    end
    C -->|"is inserted into"| R

Notice the difference from props: a prop passes a value that the child decides how to render; a slot passes markup already decided by the parent, and the child only decides where to place it.

  1. The default slot and fallback content

A <slot> without a name is the default slot: it receives all the content the parent writes between the component's tags (except whatever is aimed at named slots).

Inside <slot> you can write fallback content, which is shown only when the parent provides nothing:

<!-- Child -->
<button type="button" class="button">
  <slot>OK</slot>
</button>
<!-- Parent -->
<BaseButton />                   <!-- shows "OK" -->
<BaseButton>Book</BaseButton>    <!-- shows "Book" -->

Fallback content is useful so that a component works "as is" and, at the same time, can be customised. We will use it a lot: for example, RoomCard will have some default actions that a parent will be able to replace.

  1. Named slots

When a component has several gaps, each one has a name:

<!-- Child: BasePanel.vue -->
<template>
  <section class="panel">
    <header class="panel__header">
      <slot name="header"></slot>
    </header>
    <div class="panel__body">
      <slot></slot> <!-- no name: the default slot (its implicit name is "default") -->
    </div>
    <footer class="panel__footer">
      <slot name="footer"></slot>
    </footer>
  </section>
</template>

To direct content to a named slot, the parent uses a <template> with the v-slot:name directive, or its shorthand #name (you saw it in the shorthand table in Template Syntax):

<!-- Parent -->
<BasePanel>
  <template #header>
    <h2>Selected room</h2>
  </template>

  <!-- Everything that is not in a <template #...> goes to the default slot -->
  <p>Floor 1 · 8 people</p>

  <template #footer>
    <button>Book this room</button>
  </template>
</BasePanel>

Practical rules:

  • The order of the <template #...>s in the parent does not matter: each piece of content goes to its gap, in the order the child defines.
  • Loose content (outside any <template #...>) goes to the default slot. You can also be explicit with <template #default>.
  • v-slot can only be used on a <template> or directly on the component's tag (the latter only for the default slot; you will see this in section 5).
  • If the child has no slot with that name, the content is simply not shown (with no warning).

  1. Render scope: what a slot's content can see

A key question: inside a slot's content, which variables do you have access to? The answer is a simple rule:

A slot's content is written in the parent's template, so it sees the parent's state, not the child's.

<!-- In App.vue -->
<BasePanel>
  <template #header>
    <!-- selectedRoom belongs to App: it can be used -->
    <h2>{{ selectedRoom.name }}</h2>
  </template>
</BasePanel>

If BasePanel internally had a ref called isOpen, writing {{ isOpen }} in the content above would not work: Vue would look for it in App. It is the same rule as with functions in JavaScript: code sees the variables of the place where it is written, not of the place where it runs (lexical scope).

The slot's content... Can it?
Read the parent's data, computed properties and functions Yes
Call the parent's functions in events (@click="book") Yes: the events go straight to the parent, without re-emitting
Read the child's internal state No, unless the child passes it explicitly (section 5)
Receive the parent's scoped styles Yes: the content belongs to the parent and carries its data-v attribute

The last row has a practical consequence: if the child wants to style the content it receives in a slot, its scoped styles do not reach it; that is what the :slotted() selector we mentioned in Class and Style Bindings is for.

  1. Scoped slots: the child passes data to the parent

Sometimes the parent's content needs data that only the child has. The typical example is a list: the child goes through the items with v-for, and the parent wants to decide how each item is rendered. The parent does not know which item is being rendered each time; the child does.

Scoped slots solve this: the child passes data to the slot as if it were props, and the parent receives it in v-slot:

<!-- Child: RoomList.vue (simplified) -->
<ul>
  <li v-for="room in rooms" :key="room.id">
    <!-- Attributes on <slot> = "slot props" -->
    <slot name="room" :room :position="rooms.indexOf(room) + 1">
      {{ room.name }} <!-- fallback content -->
    </slot>
  </li>
</ul>
<!-- Parent -->
<RoomList :rooms="catalog">
  <template #room="{ room, position }">
    {{ position }}. <strong>{{ room.name }}</strong> · {{ room.capacity }} people
  </template>
</RoomList>
  • In the child, the attributes of the <slot> (except name) are the slot props. Here, room and position.
  • In the parent, #room="{ room, position }" receives those props in an object, which we destructure like a function's parameters. In fact, internally it is a function: the scoped slot is compiled as a function that the child calls once for each item, passing it the data.
  • The content can still see the parent's state too: it can combine room (from the child) with, for example, selectedRoomId (from the parent).
sequenceDiagram
    participant L as RoomList (child)
    participant P as Slot content (parent)
    loop for each room
        L->>P: calls the slot with { room, position }
        P-->>L: returns the markup for that room
    end

If the component uses only the default slot, you can put v-slot directly on its tag, without a <template>:

<CurrentTime v-slot="{ now }">
  It is {{ now.toLocaleTimeString('en-GB') }}
</CurrentTime>

But if you mix the default slot with named slots, use <template #default="..."> for all of them, or the compiler will complain about the ambiguity.

  1. Conditional slots: $slots and useSlots

In the BasePanel from section 3, if the parent provides no content for #footer, an empty <footer> is rendered anyway, with its border and padding. The right thing is to render the wrapper only if there is content. To find out, every component has the $slots object, with one property for each slot the parent has filled:

<!-- BasePanel.vue -->
<footer v-if="$slots.footer" class="panel__footer">
  <slot name="footer"></slot>
</footer>

In the script, the same object is obtained with useSlots():

import { useSlots } from 'vue'

const slots = useSlots()

function hasFooter() {
  return Boolean(slots.footer)
}

One subtlety: the slots object is not reactive. Check it in the template, or in functions that run during rendering, but do not wrap it in a computed, because the cache would not notice the changes. In practice, $slots in the template covers almost every case.

  1. Dynamic slot names

Just like the dynamic directive arguments you saw in Template Syntax, the slot name can be calculated:

<script setup>
import { computed } from 'vue'

const { hasErrors } = defineProps({ hasErrors: Boolean })
// If there are errors, the message goes at the top (header); if not, discreetly at the bottom (footer)
const messageArea = computed(() => (hasErrors ? 'header' : 'footer'))
</script>

<template>
  <BasePanel>
    <template #[messageArea]>
      <p>Please check the details before continuing.</p>
    </template>
    <!-- ... -->
  </BasePanel>
</template>

#[messageArea] is shorthand for v-slot:[messageArea]. It is a tool you will not need often, useful in components that generate their content from configurations (tables with columns defined by data, generated forms...). For simple cases, a v-if on a <template #...> is usually more readable: you can also write <template v-if="condition" #footer> to fill a slot only when a condition is met.

  1. Renderless components

Taking scoped slots to the extreme gives rise to a pattern with a name of its own: a component that renders nothing of its own and only provides logic, handing its data to the default slot. It is a renderless component:

<!-- CurrentTime.vue: clock logic, with no markup of its own -->
<script setup>
import { ref, onMounted, onUnmounted } from 'vue'

const now = ref(new Date())
let interval = null

onMounted(() => {
  interval = setInterval(() => (now.value = new Date()), 1000)
})
onUnmounted(() => clearInterval(interval))
</script>

<template>
  <slot :now></slot>
</template>
<!-- Each parent decides how to display the time -->
<CurrentTime v-slot="{ now }">
  <p class="clock">Reception · {{ now.toLocaleTimeString('en-GB') }}</p>
</CurrentTime>

The logic (the timer, the clean-up on unmounting) is reused, and the presentation is entirely in the hands of each parent. It was a widely used pattern in Vue 2 for sharing logic. In Vue 3, the same need is almost always better met with a composable (a useCurrentTime() function that returns now), which does not create an extra component instance. You will study this in The Vue 3 Composition API in Depth: Composables and Logic Reuse; that is why we will not use this pattern in Colmena, but you should recognise it when you come across it in libraries.

  1. Props or slots?

Both tools are used to customise a component from the outside. This table will help you choose:

Situation Best option Example in Colmena
The parent passes a piece of data that the child knows how to render Prop room in RoomCard, status in StatusBadge
The parent passes plain text that is always rendered the same way Prop label in TextField
The parent passes markup: formatted text, icons, other components Slot The content of BaseButton
The component defines a structure with areas and the content varies a lot Named slots BasePanel with header, body and footer
The child has the data and the parent decides how to render each item Scoped slot Each room in RoomList
What arrives has to be validated, or the child needs the value for a calculation Prop Validated variant in BaseButton
A finite set of visual variants Prop variant="danger"

A rule in a nutshell: props are for data; slots are for content. If you find yourself adding props such as buttonText, buttonIcon, showIcon, iconPosition... to control every detail of what is rendered, you probably needed a slot.

  1. Case study: BaseButton, BasePanel and slots in the catalogue

10.1 BaseButton.vue

Since 03-01, the .button class has been a temporary global style. The time has come to replace it with a generic component with its own encapsulated style. Create src/components/base/BaseButton.vue:

<script setup>
const { variant = 'primary' } = defineProps({
  variant: {
    type: String,
    validator: (value) => ['primary', 'secondary', 'danger'].includes(value)
  }
})
</script>

<template>
  <button type="button" class="button" :class="`button--${variant}`">
    <span v-if="$slots.icon" class="button__icon" aria-hidden="true">
      <slot name="icon"></slot>
    </span>
    <slot>OK</slot>
  </button>
</template>

<style scoped>
.button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.2rem;
  border: 2px solid transparent;
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
}

.button--primary {
  background: var(--color-honey-dark);
  color: white;
}

.button--secondary {
  border-color: var(--color-honey-dark);
  background: white;
  color: var(--color-text);
}

.button--danger {
  background: #c62828;
  color: white;
}

/* Pressed toggle button (active filters) */
.button[aria-pressed='true'] {
  outline: 3px solid var(--color-text);
  outline-offset: 2px;
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.button__icon {
  display: inline-flex;
}
</style>
  • The default slot is the button's text, with "OK" as fallback content.
  • The #icon slot is optional and conditional: the <span> that wraps it only exists if the parent fills it. aria-hidden="true" makes the screen reader ignore the decorative icon and read only the text.
  • variant is a validated prop: three finite looks, the case from the previous table.
  • type="button" by default: that way a BaseButton inside a form does not submit it by accident. For the submit button, the parent will write type="submit", and that value will replace the component's. How do the parent's type, disabled, aria-pressed or @click reach the inner <button> without being declared as props? Thanks to fallthrough attributes, which we will study in depth in the next lesson. For now, it is enough to know that, when a component has a single root element, attributes and events that are neither props nor declared events are applied to that element.
  • .button[aria-pressed='true'] replaces the old .button--active class: the style of the active filter is derived from the accessibility attribute itself, as we did with aria-invalid in the form.

Now replace the components' <button class="button">s with BaseButton (import it in each one from ./base/BaseButton.vue, or ../base/BaseButton.vue depending on the folder). Some examples:

<!-- AppHeader.vue -->
<BaseButton variant="secondary" @click="toggleClock">
  {{ showClock ? 'Hide clock' : 'Show clock' }}
</BaseButton>

<!-- RoomFilters.vue: the filters indicate their state with aria-pressed -->
<BaseButton variant="secondary" :aria-pressed="floor === null" @click="floor = null">
  All
</BaseButton>
<BaseButton
  v-for="number in 3"
  :key="number"
  variant="secondary"
  :aria-pressed="floor === number"
  @click="floor = number"
>
  {{ number }}
</BaseButton>

<!-- App.vue: retry button with an icon -->
<BaseButton @click="reloadRooms">
  <template #icon>↻</template>
  Retry
</BaseButton>

<!-- BookingForm.vue -->
<BaseButton type="submit" :disabled="!formIsValid">Book</BaseButton>
<BaseButton variant="secondary" @click="resetForm">Reset</BaseButton>

In RoomFilters, all the filter buttons (floor, capacity, equipment and sort order) switch to using :aria-pressed with a Boolean condition instead of :class="{ 'button--active': ... }": Vue converts true and false into the strings "true" and "false" in attributes such as aria-pressed, which are not HTML Boolean attributes. In ShortcutsHelp, write <BaseButton class="button--help" ...>: the class is added to the component's own classes, and ShortcutsHelp's scoped styles reach it because it is the child's root element. The search box's "Clear" button can use variant="secondary" and a ✕ icon.

When there is no class="button" left, delete the .button, .button:disabled and .button--active rules from src/assets/main.css. The temporary global style has gone: every button in the application is now a BaseButton with its styles encapsulated.

10.2 BasePanel.vue

Create src/components/base/BasePanel.vue, with the structure from section 3 and the conditional wrappers:

<template>
  <section class="panel">
    <header v-if="$slots.header" class="panel__header">
      <slot name="header"></slot>
    </header>
    <div class="panel__body">
      <slot></slot>
    </div>
    <footer v-if="$slots.footer" class="panel__footer">
      <slot name="footer"></slot>
    </footer>
  </section>
</template>

<style scoped>
.panel {
  margin: 1.5rem 0;
  border-radius: 10px;
  background: white;
  overflow: hidden;
}

.panel__header,
.panel__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--color-background);
}

.panel__body {
  padding: 1rem;
}
</style>

BasePanel has no script: it is pure structure. Use it in App.vue for the selected room, replacing the <section class="selection">:

<BasePanel>
  <template #header>
    <h2>Selected room: {{ selectedRoom.name }}</h2>
    <StatusBadge :status="selectedRoom.available ? 'available' : 'unavailable'" />
  </template>

  <dl class="spec-sheet">
    <template v-for="(value, key) in specSheet" :key="key">
      <dt>{{ key }}</dt>
      <dd>{{ value }}</dd>
    </template>
  </dl>
  <p v-if="!selectedRoom.available" class="notice">This room is under maintenance.</p>

  <template #footer>
    <BaseButton
      :disabled="!selectedRoom.available"
      @click="prepareBooking({ roomId: selectedRoom.id, attendees: 1 })"
    >
      Book this room
    </BaseButton>
  </template>
</BasePanel>

And for the list of bookings, inside the booking section:

<BasePanel>
  <template #header>
    <h3>Bookings created in this session</h3>
    <span>{{ bookings.length }}</span>
  </template>

  <p v-if="bookings.length === 0">You have not created any bookings yet.</p>
  <ul v-else class="booking-list">
    <!-- the bookings' <li>s, no changes -->
  </ul>
</BasePanel>

In this second panel there is no #footer and, thanks to v-if="$slots.footer", no empty <footer> is rendered. Notice the render scope in action too: the content uses selectedRoom, specSheet, bookings and prepareBooking, all of which belong to App, and App's scoped styles (.spec-sheet, .notice) are applied to the content because it belongs to App.

10.3 RoomCard with an #actions slot

The card's "Select" and "Book" buttons are right for the catalogue, but other actions might be needed in another context. Turn the actions block into a named slot, with the current actions as fallback content and passing useful data to the parent. In RoomCard.vue, import BaseButton and replace the <div class="card__actions">:

<div class="card__actions">
  <slot name="actions" :room :attendees :full>
    <BaseButton variant="secondary" :disabled="selected" @click="select">
      {{ selected ? 'Selected' : 'Select' }}
    </BaseButton>
    <BaseButton :disabled="!room.available" @click="book">Book</BaseButton>
  </slot>
</div>
  • If the parent does not fill #actions, everything works as before.
  • If it does, it receives as slot props the room, the number of attendees set on the card and whether it is full: internal data of the card that the parent could not know any other way.

10.4 RoomList with a #room scoped slot

Now for the most interesting piece. Modify the template of RoomList.vue so that each item is a scoped slot, with the current card as fallback content:

<template>
  <ul class="room-list">
    <li v-for="room in rooms" :key="room.id">
      <slot name="room" :room :selected="room.id === selectedId">
        <RoomCard
          :room
          :selected="room.id === selectedId"
          @select="emit('select', $event)"
          @book="emit('book', $event)"
        />
      </slot>
    </li>
  </ul>
</template>

RoomList keeps working in exactly the same way if nobody uses the slot. But now App can take control of how each room is rendered. Use it in App.vue to improve the catalogue: for unavailable rooms, instead of two disabled buttons, we will show a clear message. Replace the catalogue's <RoomList>:

<RoomList :rooms="visibleRooms">
  <template #room="{ room }">
    <RoomCard
      :room
      :selected="room.id === selectedRoomId"
      @select="selectRoom"
      @book="prepareBooking"
    >
      <template v-if="!room.available" #actions>
        <p class="notice">Under maintenance: not accepting bookings.</p>
      </template>
    </RoomCard>
  </template>
</RoomList>

Let's analyse what has changed, because it brings together everything in the lesson:

  • #room="{ room }": RoomList goes through the rooms and, for each one, calls the slot, passing it room. App decides how to render it.
  • The content sees App's state: selectedRoomId, selectRoom and prepareBooking belong to App. That is why the card's events go directly to App, without RoomList having to re-emit them: there is no longer any need to pass it :selected-id or to listen to its events.
  • <template v-if="!room.available" #actions> fills the card's slot only for unavailable rooms. For the rest, the card uses its default actions.
  • .notice is shown in red and bold with App's styles, because the paragraph belongs to App.

We now have two ways of using RoomList: "as is", with its props and events, or customising each item with the slot. Both are valid and coexist in the same component.

Finally, a note about something we announced in Event Handling: the BaseModal that will replace window.confirm is built with slots like those in BasePanel, but it also needs Teleport to be displayed above the whole page. We will build it in Teleport, Suspense and Error Handling.

10.5 Try it

  1. All the buttons in the application now look the same, with variants. Active filters are marked with the outline, thanks to aria-pressed. Inspect one: you will see aria-pressed="true" on the <button>.
  2. Trigger the loading error (raise ERROR_PROBABILITY to 1 in src/api/rooms.js): the "Retry" button shows its icon. Set it back to 0.1.
  3. Look at the Enjambre Auditorium card: instead of the buttons, it shows "Under maintenance: not accepting bookings.". The others keep their actions.
  4. The bookings panel has no footer; the selected room's panel does. Inspect the first one: there is no <footer> at all.
  5. In Vue DevTools, select RoomList: it no longer receives selectedId. Select a RoomCard: its parent in the tree is still RoomList, even though its content was written by App.

Common Mistakes and Tips

  • Trying to use the child's state in the slot's content. The content sees the parent's scope. If you need data from the child, the child must pass it as slot props.
  • Using v-slot on an HTML element. It only works on <template> or on the component's tag.
  • Mixing v-slot on the component's tag with <template #...>. If there are named slots, use <template #default> for the default one.
  • Rendering empty wrappers. Check $slots.name before rendering the container of an optional slot.
  • Wrapping useSlots() in a computed property. The slots object is not reactive.
  • Turning everything into slots. For simple data, a prop is clearer, and it is validated and documented better.
  • Expecting the child's scoped styles to reach the slot's content. The content belongs to the parent; use :slotted() in the child if it is essential.
  • Tip: always give slots sensible fallback content. The component will be usable without any configuration and customisable when needed.

Exercises

Exercise 1. Add a Boolean loading prop to BaseButton. While it is true, the button must be disabled and must show a ⟳ inside the icon's own <span>, instead of the icon the parent passes it, keeping the text. Hint: a slot's fallback content can depend on a condition, but here what you want is to replace the slot.

Exercise 2. Use RoomCard's #actions slot from App.vue so that, for available rooms, the "Book" button shows how many attendees are going to be booked ("Book 3 people") and is disabled if there are 0. Keep showing the maintenance message for unavailable rooms. Hint: you will need v-if/v-else on two <template>s with the same slot name.

Exercise 3. State what is displayed in each case and why, given that BasePanel (supposedly) has a const title = 'Panel' in its script, and that App has const title = 'Colmena':

<!-- a -->
<BasePanel>{{ title }}</BasePanel>

<!-- b -->
<BasePanel>
  <template #footer>Footer</template>
</BasePanel>

<!-- c -->
<BasePanel>
  <template #sidebar>Sidebar</template>
  Body
</BasePanel>

Solutions

Solution 1.

<script setup>
const { variant = 'primary', loading = false, disabled = false } = defineProps({
  variant: {
    type: String,
    validator: (value) => ['primary', 'secondary', 'danger'].includes(value)
  },
  loading: Boolean,
  disabled: Boolean // now it is a prop: the component needs to combine it with loading
})
</script>

<template>
  <button
    type="button"
    class="button"
    :class="`button--${variant}`"
    :disabled="disabled || loading"
    :aria-busy="loading"
  >
    <span v-if="loading || $slots.icon" class="button__icon" aria-hidden="true">
      <template v-if="loading">⟳</template>
      <slot v-else name="icon"></slot>
    </span>
    <slot>OK</slot>
  </button>
</template>
  • The <span> appears if there is an icon or if it is loading.
  • Inside it, v-if/v-else chooses between the loading symbol and the slot: a <slot> accepts directives like any other element.
  • disabled becomes a prop. Until now it reached the <button> as a fallthrough attribute, without being declared; but now the component needs to combine it with loading (disabled || loading), and to read a value in the script or the template it has to be declared. If you did not declare it, the parent's disabled would be applied directly to the button and could override yours: you will see how a component's own attributes are combined with fallthrough ones in the next lesson.
  • aria-busy tells assistive technologies that the button is busy.

Solution 2.

<RoomCard
  :room
  :selected="room.id === selectedRoomId"
  @select="selectRoom"
  @book="prepareBooking"
>
  <template v-if="!room.available" #actions>
    <p class="notice">Under maintenance: not accepting bookings.</p>
  </template>
  <template v-else #actions="{ attendees }">
    <BaseButton variant="secondary" :disabled="room.id === selectedRoomId" @click="selectRoom(room.id)">
      {{ room.id === selectedRoomId ? 'Selected' : 'Select' }}
    </BaseButton>
    <BaseButton
      :disabled="attendees === 0"
      @click="prepareBooking({ roomId: room.id, attendees })"
    >
      Book {{ attendees }} people
    </BaseButton>
  </template>
</RoomCard>

By replacing the slot, the parent takes charge of all the actions, including "Select", which no longer comes from the fallback content. attendees arrives from the card as a slot prop: it is the child's internal state, which the parent could not know any other way. The buttons call App's functions directly (render scope), without going through the card's events. Remember to import BaseButton in App.vue.

Solution 3.

  • (a) It shows "Colmena": the slot's content is compiled in App's template and sees App's title, not the panel's.
  • (b) It shows the "Footer" text in a <footer>, the empty <div class="panel__body"> (the default slot has no fallback content) and no <header>, because $slots.header does not exist.
  • (c) It shows "Body" in the body. "Sidebar" is not shown: BasePanel has no slot called sidebar, and Vue discards it without warning.

Conclusion

Slots let the parent inject markup into gaps the child defines: the default slot, with its fallback content, and named slots, filled with <template #name>. A slot's content belongs to the parent: it sees the parent's state and styles, not the child's (render scope). When the content needs data from the child, scoped slots pass it as slot props (#room="{ room }"), which lets a list component delegate to the parent how each item is rendered. $slots (or useSlots()) lets you render wrappers only when there is content, slot names can be dynamic and, taken to the extreme, the pattern gives rise to renderless components, which nowadays are almost always replaced by composables. The general rule: props for data, slots for content. Colmena now has BaseButton (with variants and an #icon slot), which has eliminated the global .button style, BasePanel with header, body and footer, a RoomCard with customisable actions and a RoomList whose scoped slot lets App decide how each room is rendered.

In this lesson we have taken advantage of something without explaining it: attributes such as type, disabled, aria-pressed or class, and events such as @click, reach BaseButton's inner <button> without being declared as props. And TextField is still dragging along two patches (inputType and the blur event) because things do not work the same way in it. In Template Refs and Fallthrough Attributes we will understand that mechanism, learn how to control it and how to access DOM elements and child components directly, for example to move the focus to the first field with an error in the form.

New edition · October 2026

Vue.js Course

Module 1: Introduction to Vue.js

Module 2: Vue.js Basics

Module 3: Vue.js Components

Module 4: Vue Router

Module 5: State Management with Vuex and Pinia

Module 6: Vue.js Directives

Module 7: Vue.js Plugins

Module 8: Testing in Vue.js

Module 9: Advanced Vue.js Concepts

Module 10: Building and Deploying Vue.js Applications

Module 11: Real-World Vue.js Projects

© Copyright 2026. All rights reserved