I have a Lightning-formatted-text tag in place which displays error from JS and apex controller. Now I want this error to be displayed along with error icon on the component. Below is the HTML code:

 <lightning-formatted-text icon-name="utility:error" class="slds-text-color_error" value={warningMessage}></lightning-formatted-text>

Now when the error occurs on the component, I am getting error message, but not error icon. When I use Lightning-icon tag, the error icon is displaying even before the error message is displayed. Like it is staying on the page all the time.

Can anyone help me out here

1 Answer 1


lightning-formatted-text doesn't have an icon-name attribute.

You can display the icon separately, and only when there's an error, like this:

<lightning-icon icon-name="utility:error" if:true={warningMessage}>
  • This worked..Thanks :)
    – Kirshna
    Commented Jun 9, 2020 at 15:22

You must log in to answer this question.

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