Skip to content
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

Pass arbitrary properties to slot #5456

Closed
SeanAllanMacKay opened this issue Sep 24, 2020 · 3 comments · Fixed by #5616
Closed

Pass arbitrary properties to slot #5456

SeanAllanMacKay opened this issue Sep 24, 2020 · 3 comments · Fixed by #5616

Comments

@SeanAllanMacKay
Copy link

Is your feature request related to a problem? Please describe.
I have run into cases where it would be nice to be able to pass arbitrary props to a slot, similar to the ability to spread the $$props global over a regular component.

A specific use case was having a generic link wrapper that would wrap any arbitrary components, which would require passing through all properties without knowing what could be present. The consuming component would know what would be present, but not the wrapper itself.

Trying to spread properties over a slot results in a <slot> cannot have directives error

Describe the solution you'd like
I would like to see a way to pass through arbitrary properties to slot components. The first idea that comes to mind is allowing the spreading of props over a slot.

<slot {...$$props} />

Describe alternatives you've considered
As an alternative I have written component specific wrappers rather than generic wrappers.

How important is this feature to you?
It's more of a nicety than a necessity, but I have encountered situations where this would have been handy on more than one occasion.

@TylerRick
Copy link

I have wished for this as well...

@pushkine
Copy link
Contributor

Similarly, it could be useful to have a catch-all for the let: directive

<Component let:$$lets>
    <slot {...$$lets} />
</Component>

@Conduitry
Copy link
Member

Version 3.30.0 now lets you use spread props in slots: <slot {...foo} />

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 a pull request may close this issue.

4 participants