Svelte • Legacy APIs
$$slots
In runes mode, we know which snippets were provided to a component, as they’re just normal props.
In legacy mode, the way to know if content was provided for a given slot is with the $$slots object, whose keys are the names of the slots passed into the component by the parent.
<div>
<slot name="title" />
{#if let $$slots: Record<"title" | "description", boolean>$$let $$slots: Record<"title" | "description", boolean>slots.description: booleandescription}
<!-- This <hr> and slot will render only if `slot="description"` is provided. -->
<hr />
<slot name="description" />
{/if}
</div><Card>
<h1 slot="title">Blog Post Title</h1>
<!-- No slot named "description" was provided so the optional slot will not be rendered. -->
</Card>