1

I have a custom label "This seat is already matched to another student. Please remove the existing match before matching this student." I want to display "Please remove the existing match before matching this student." in another line line in LWC HTML. HTML code:

<div class="slds-notify slds-notify_alert" role="alert">{label.match_success}</div>

Can we directly mention something in custom label so that it comes in new line or I have to manipulate in js file?

2
  • 2
    I have not tried, but can you adding html tag and in lwc use lighting formatted rich text tag. Commented Jul 10, 2021 at 16:27
  • Thanks, it worked. Commented Jul 10, 2021 at 16:42

2 Answers 2

2

Adding my comment as answer.

For this we can use lightning-formatted-rich-text and add html tags in our custom labels.

For eg:

<lightning-formatted-rich-text value={label.labelWithHtml}></lightning-formatted-rich-text>

Label:

<labels>
    <fullName>labelWithHtml</fullName>
    <categories>UI_Message</categories>
    <language>en_US</language>
    <protected>fa</protected>
    <shortDescription>labelWithHtml</shortDescription>
    <value>labelWithHtml <br> labelWithHtml</value>
</labels>
1
  • I get the error Unexpected element {http://soap.sforce.com/2006/04/metadata}br during simple type deserialization when including <br> tags in the label value Commented Jan 1 at 20:46
0

As mentioned by Nagendra, I used lightning formatted rich text tag

<lightning-formatted-rich-text value={label.empty_table}></lightning-formatted-rich-text>

and updated my label with "br" tag.

You must log in to answer this question.

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