-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Make :let directive value available in slot definition #4966
Comments
I can't really figure out what you're trying to do here, because it's not clear where Howeve, this isn't how you'd apply that class. You'd use the class directive: <ListboxOption value={item} class:i-am-active={active}>{item.name}</ListboxOption> Not sure if this helps you or not. |
this seems entirely unrelated A component can provide a variable to back to the parent, as documented here: https://svelte.dev/docs#slot_let this is how it is expected to work <!-- App.svelte -->
<FancyList {items} let:prop={thing}>
<div>{thing.text}</div>
</FancyList>
<!-- FancyList.svelte -->
<ul>
{#each items as item}
<li class="fancy">
<slot prop={item}></slot>
</li>
{/each}
</ul> however if I wanted to use THIS WORKS<!-- App.svelte -->
<FancyList {items} let:prop={thing}>
<div>{thing.text}</div>
</FancyList> DOES NOT WORK, BUT I WOULD LIKE IT TOnotice that the <!-- App.svelte -->
<FancyList {items} let:prop={thing} id={thing.text}>
<div></div>
</FancyList> example repl: https://svelte.dev/repl/2bb7298f885f403eb6cfe1decaa413de?version=3.23.2 |
It will not going to work this way.
<FancyListItem {item} let:className class={className}>
<div>{className}</div>
</FancyListItem>
|
I understand, and suspect that it will not be feasible. re:
just want to note that this is an example of what is not working. In a RWA, I would be doing something like providing a boolean to the parent, so the parent may assign the class. <ListboxOption
value={item}
let:active
class:lb-active="{active}"
>{item.name}</ListboxOption> this would allow for easier creation of reusable components where the styling can be be determined by the parent component, without having to provide a huge list of potential parameters that the implementation may use. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
the example in the tutorial of this subject does not work either! |
Closing since |
Is your feature request related to a problem? Please describe.
I'd like to have the slot variables available within the definition. Currently I cannot use the variable to define value for
class
attributeDescribe the solution you'd like
ie:
Describe alternatives you've considered
I can retrieve the
activeValue
value, in this scenario, from another component higher up the chain and compute.alternatively, I could just nest the element
How important is this feature to you?
a nice to have
Additional context
reference: https://github.com/dasDaniel/svelte-listbox/blob/master/example/src/App.svelte
The text was updated successfully, but these errors were encountered: