0

I am using below code for lightning-combobox in lwc HTML file

<lightning-combobox  value={value} label={labelWonLostReason}  onchange={handleWonLostRegionChange} options={filteredWonLostRegionValues}
                            name="progress" read-only={wonLostReason}> </lightning-combobox> 

here for label 'labelWonLostReason' I am using below code in javascript

this.labelWonLostReason = "*" + "Won Lost Reason";

I need to make this asterisk (*) in red color. There is one property 'required' of lightning-combobox but I can not use that.

How can I achieve this behavior. in Java there is something like HTML.formHTML which format the text to html at run time. Is there something similar I can use here ?

Thanks in Advance

1 Answer 1

0

Might be good idea to go back to business and ask if they really need it. "Don't surprise the user", don't think the functionality is oh so special for it to look different from the rest of core Salesforce...

Can you use variant="label-hidden" and create your own custom html <label> paired with the combobox? https://www.lightningdesignsystem.com/components/combobox/ contains raw HTML, you probably could steal bits of that but combine it with regular tag, just with the label hidden

Alternatively look into the https://github.com/salesforce/base-components-recipes/blob/master/force-app/main/default/lwc/combobox/combobox.html (or better: https://www.npmjs.com/package/lightning-base-components) to create your own components behaving identical to built-in ones and then you could keep hacking at them, create perfect <c-combobox> to use in your projects?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.