profile
viewpoint

Ask questionsA way to see if slot prop is present

v3.0.0-beta.5

Before #2083 it was possible to check if slot prop is present

<svelte:options bind:props/>
<div>
	{#if props.$$slot_icon}
		<div class="Input-Icon">
			<slot name="icon"></slot>
		</div>
	{/if}
</div>

An option to see if a slot prop is preset would be nice to have.

sveltejs/svelte

Answer questions evanleck

Maybe $$slots like $$props? My use case is that I'd like to wrap a slot's content in an element that applies styling that I'd like absent without the slotted content. Something like this:

{#if $$slots.description}
  <div class="description">
    <slot name="description"></slot>
  </div>
{/if}
useful!
source:https://uonfu.com/
Github User Rank List