[✨] Enable the attribute q:slot on Fragment #141
phcoliveira
started this conversation in
Proposals For Qwik
Replies: 2 comments
-
Something similar occurs when one wants to project multiple items into the same Slot. Currently I have to do: export default component$(() => {
return (
<ResponsiveSidebar>
<li q:slot="item">
<a>hello</a>
</li>
<li q:slot="item">
<a>hello</a>
</li>
<li q:slot="item">
<a>hello</a>
</li>
<Slot />
</ResponsiveSidebar>
);
}); and I believe wrapping them in a fragment to reuse the slot name would be helpful: export default component$(() => {
return (
<ResponsiveSidebar>
<q:slot="item">
<li>
<a>hello</a>
</li>
<li>
<a>hello</a>
</li>
<li>
<a>hello</a>
</li>
</>
<Slot />
</ResponsiveSidebar>
);
}); |
Beta Was this translation helpful? Give feedback.
0 replies
-
We moved this issue to |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is your feature request related to a problem?
Yes, so to say.
When you use the default slot, it is possible to pass only text. And this is very useful if you want to ensure such copy should aways look the same. Like in:
However, it is not possible to do so when using named slots because you need an HTML Element onto which the attribute
q:slot
is attached.The consumer of
Post
, when passing content to the named slottitle
, needs to do it with an element. Possibly aspan
, but an inconvenience nonetheless.Describe the solution you'd like
I would like that the
Fragment
component could accept theq:slot
attribute. That way, considering the componentPost
, from above, it would be possible to pass only text to the title.Describe alternatives you've considered
I have been using "harmless" elements, like
span
, to pass text to named slots. But it is not a perfect solution.Additional context
I created a discussion about it on Discord.
https://discord.com/channels/842438759945601056/1134954295897358417
Beta Was this translation helpful? Give feedback.
All reactions