1

I have a requirement to add the registered TM symbol in superscript to some LWC combo box menus. The options array that you pass into the combo box does not seem to support any sort of String interpolation.

This won't work

 options = [{       
        {label: `product®`, value: 'product'}
    ]

Is there a way to do this with combox box? I can make it work by hard coding the values into a standard HTML

 <select name="cars" id="product">            
            <option value="test">{textVal}&#0174;</option>
        </select>
    enter code here

 

2 Answers 2

3

You don't need to escape Unicode in LWC. Use the literal character in your source code:

  options = [
    { label: 'Product®', value: 'Product®' }
  ];
1
  • And here I thought the only way to display it was with Unicode. Thanks Brian Commented Jul 27, 2021 at 11:18
4

Use lightning-formatted-text

<select name="cars">            
  <template for:each={options} for:item="option">
      <option value={option.value} key={option.value}>
         <lightning-formatted-text value="{option.label}" ></lightning-formatted-text>
      </option>
  </template>
</select>
1
  • That is a good idea. I had just started looking for non base-compenent solutions. Commented Jul 26, 2021 at 20:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .