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

How to have custom label per item #586

Closed
EddTally opened this issue Apr 11, 2023 · 2 comments
Closed

How to have custom label per item #586

EddTally opened this issue Apr 11, 2023 · 2 comments

Comments

@EddTally
Copy link

Pre v5 we had these options, getOptionLabel & getSelectionLabel.
This allowed us to edit how the label was displayed, like so:

getOptionLabel={(option) => `Item Id: ${option.itemId}, Item Name: ${option.itemName}`}
getSelectionLabel={(option) => `Selected Id: ${option.itemId}, Selected Name: ${option.itemName}`}

I read the docs but cannot find a replacement for this functionality.
Could I get some help please.

@rob-balfre
Copy link
Owner

rob-balfre commented Apr 11, 2023 via email

@EddTally
Copy link
Author

EddTally commented Apr 11, 2023

Named slots.

So I would do something like

<div slot="item" let:item > Item Id: {item.itemId}, Item Name: {item.itemName} </div>
<div slot="selection" let:selection > Selected Id: {selection.itemId}, Selected Name: {selection.itemName} </div>

These are new to me, just learned from here https://svelte.dev/tutorial/slot-props

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

No branches or pull requests

2 participants