@ -1292,19 +1292,19 @@ Components can have child content, in the same way that elements can.
The content is exposed in the child component using the `<slot>` element, which can contain fallback content that is rendered if no children are provided.
The content is exposed in the child component using the `<slot>` element, which can contain fallback content that is rendered if no children are provided.
```sv
```sv
<!-- App.svelte -->
<Widget></Widget>
<Widget>
<p>this is some child content that will overwrite the default slot content</p>
</Widget>
<!-- Widget.svelte -->
<!-- Widget.svelte -->
<div>
<div>
<slot>
<slot>
this fallback content will be rendered when no content is provided, like in the first example
this fallback content will be rendered when no content is provided, like in the first example
</slot>
</slot>
</div>
</div>
<!-- App.svelte -->
<Widget></Widget><!-- this component will render the default content -->
<Widget>
<p>this is some child content that will overwrite the default slot content</p>
</Widget>
```
```
#### [`<slot name="`*name*`">`](slot_name)
#### [`<slot name="`*name*`">`](slot_name)
@ -1314,18 +1314,18 @@ The content is exposed in the child component using the `<slot>` element, which
Named slots allow consumers to target specific areas. They can also have fallback content.
Named slots allow consumers to target specific areas. They can also have fallback content.
@ -1337,20 +1337,21 @@ Named slots allow consumers to target specific areas. They can also have fallbac
Note that explicitly passing in an empty named slot will add that slot's name to `$$slots`. For example, if a parent passes `<div slot="title" />` to a child component, `$$slots.title` will be truthy within the child.
Note that explicitly passing in an empty named slot will add that slot's name to `$$slots`. For example, if a parent passes `<div slot="title" />` to a child component, `$$slots.title` will be truthy within the child.
```sv
```sv
<!-- App.svelte -->
<Card>
<h1slot="title">Blog Post Title</h1>
</Card>
<!-- Card.svelte -->
<!-- Card.svelte -->
<div>
<div>
<slotname="title"></slot>
<slotname="title"></slot>
{#if $$slots.description}
{#if $$slots.description}
<!-- This slot and the <hr> before it will not render. -->
<!-- This <hr> and slot will render only if a slot named "description" is provided. -->
<hr>
<hr>
<slotname="description"></slot>
<slotname="description"></slot>
{/if}
{/if}
</div>
</div>
<!-- App.svelte -->
<Card>
<h1slot="title">Blog Post Title</h1>
<!-- No slot named "description" was provided so the optional slot will not be rendered. -->