Skip to content

Conditional Slots #64

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Conversation

tanhauhau
Copy link
Member

@tanhauhau tanhauhau commented Apr 12, 2022

@techniq
Copy link

techniq commented May 6, 2022

@tanhauhau Sounds like this might be able to handle $$slots with slot forwarding?

@tanhauhau
Copy link
Member Author

@tanhauhau Sounds like this might be able to handle $$slots with slot forwarding?

@techniq yea, so you would write:

<Field>
   {#if $$slots.label}
	<slot name="label" slot="label" />
   {/if}
   {#if $$slots.description}
	<slot name="description" slot="description" />
   {/if}
</Field>

@brandonmcconnell
Copy link

I would also very much like to see this added to resolve the same issue mentioned above, a rather common issue when working with slots in Svelte: $$slots with slot forwarding

@TristanBrotherton
Copy link

I am very much in need of this as forwarded slots as currently implemented is pretty broken with no work-around for checking of content. See: https://svelte.dev/repl/1757f88780b644519bb30c2b68b10873?version=3.55.1

@risalfajar
Copy link

Any reason this hasn't been merged yet?
I also need this.

@dummdidumm
Copy link
Member

Conditional slots will be possible in Svelte 5 through snippets and render tags. Whether or not we want to add syntax sugar with if+snippet inside remains to be seen. Closing this RFC - thank you.

@dummdidumm dummdidumm closed this Nov 16, 2023
@brandonmcconnell
Copy link

@dummdidumm @tanhauhau

Outside of Svelte 5, this PR introduces a valuable and foundational solution to slot forwarding across both methodologies — with and without runes — simply by using {#if}.

Could we merge this in addition to the other very welcome solutions?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants