ui5-webcomponents icon indicating copy to clipboard operation
ui5-webcomponents copied to clipboard

MultiComboBox - support custom styling on selected items/tokens

Open sunnyyadav100 opened this issue 6 years ago • 6 comments

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.

sunnyyadav100 avatar Jan 03 '20 13:01 sunnyyadav100

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

fifoosid avatar Jan 03 '20 14:01 fifoosid

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).

fifoosid avatar Jan 03 '20 15:01 fifoosid

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

fifoosid avatar Jan 06 '20 13:01 fifoosid

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:

Screenshot 2020-02-07 at 1 51 59 PM

ilhan007 avatar Feb 07 '20 11:02 ilhan007

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!!

sunnyyadav100 avatar Feb 08 '20 10:02 sunnyyadav100

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

ilhan007 avatar Feb 08 '20 11:02 ilhan007