Skip to content

Suggestion: Allow to pass named slots from nested components #2542

@OEvgeny

Description

@OEvgeny

Imagine I have a main-view component:

<template>
  <header>
      <slot name="header">
         <default-header></default-header>
      </sloot>
  </header>
  <main class="content-container">
     <slot name="content">
         <h1>404</h1>
         <p>There is no content. Sorry!</p>
     </slot>
  </main>
</template>

And I need to dynamically switch slots from the other components.

In that case my App component should look like:

<template>
  <main-view>
     <component :is="currentView"></component>
  </main-view>
</template>

<script>
  export default {
    data {
      currentView: 'index'
    }
  }
</script>

And index component:

<template>
  <div slot="content">
   ...
  </div>
<template>

For now it is possible to use only one content insertion point. So named slots from nested component are not supported. My suggestion is to allow (some-way) to export components slots to the parent component.

What are your thought on this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions