Skip to content

Improve documentation on fallback content for slots #8302

@sasoria

Description

@sasoria

📚 Subject area/topic

Fallback Content for Slots

📋 Suggested page

https://docs.astro.build/en/basics/astro-components/#fallback-content-for-slots

📋 General description or bullet points (if proposing new content)

There is a case where the default fallback content for slots is not displayed. This has been discussed on this issue in the withastro/astro repo.

So given component A and B below, the default fallback content is not shown when <slot name="s" slot="s" /> is present and empty. That is, when the slot is empty in component A, the fallback content is not shown.

Component B

<slot name="s">
  <div>Default content</div>
</slot>

Component A

<B>
  <slot name="s" slot="s" />
</B>

As Mathew wrote in the issue mentioned earlier, "Default content is rendered when a slot is not provided. Not when it is empty." This should be documented in the section about Fallback Content for Slots.

🖥️ Reproduction of code samples in StackBlitz

Link to the fallback behaviour on Stackblitz

Metadata

Metadata

Assignees

No one assigned

    Labels

    add new contentDocument something that is not in docs. May require testing, confirmation, or affect other pages.good first issueGood for newcomershelp wantedIssues looking for someone to run with them!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions