MultiComboBox - support custom styling on selected items/tokens
Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Selected values can have different styling such as background color. This component is very useful for tagging use-case.
https://codesandbox.io/s/ui5-webcomponents-v6846 https://codesandbox.io/s/ui5-webcomponents-j9m9w
Describe the solution you'd like A clear and concise description of what you want to happen.
Provide a slot to define custom templates for selected token/items.
Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.
Additional context Add any other context or screenshots about the feature request here.
Hi @sunnyyadav100,
Thanks for the feature request! We are going to discuss it internally and come back to you with a statement.
In the meantime you can use a workaround in order to style the selected items in the multicombobox. Here is an example how you can achieve this using addCustomCSS method: https://codesandbox.io/s/ui5-webcomponents-9or2i
Best regards, Filip
This is the target design: https://codesandbox.io/s/ui5-webcomponents-j9m9w
Every token should have different color(while when in the popover, they should behave like regular list items).
We are evaluating this feature request, and currently we don't imagine adding a slot for this use case. We are thinking about approach using css parts: #843
Best regards, Filip
Hello @sunnyyadav100 should you support IE11, because css parts are not supported in IE11 currently.
Otherwise,
we can set a part attribute for every token, something like token-${tokenText}
that can be styled from outside via the ::part selector:
ui5-multi-combobox::part(token-Cosy){
background-color: red;
}
ui5-multi-combobox::part(token-Condensed){
background-color: green;
}
and the result would be:

Yes , we support IE11 but we encourage our users to use modern browsers for better experience. I can try this and get back with feedback. Thanks!!
Hello @sunnyyadav100 I see.
Note that the tokens html elements currently don`t have the part="token-{some_unique_key}" attribute. It was just a quick POC on my machine to show you and ask if this approach would be fine for you. You can't test it right now.
I think that we can provide that "part" attribute soon, because it gives a standard (in most of the browsers) way to customize the tokens from outside.
Best, ilhan