How to Open Links in a Rich Text Component in the Same Tab

How to Open Links in a Rich Text Component in the Same Tab

The Rich Text component in a Lightning page allows you to easily add formatted text, links, images, and other content directly onto the page. It is a simple way to enhance your Lightning pages with helpful information, instructions, or external resources. Since it’s a Rich Text component, it allows adding links, but the links open in a new tab by default. There’s no option to control the target behavior of the links, and no plain text mode to enter HTML directly. Because of this, it’s not possible to set links to open in the same tab using standard options. However, you can achieve this with a simple workaround. Here’s how to open links in a Rich Text component on a Lightning page in the same tab.

Using Custom Label in Rich Text Component

Although the Rich Text component doesn’t have a resource picker, it does allow using custom labels. You just need to type them manually in the correct format. With custom labels, you can control the text externally, so you won’t have to update multiple Lightning pages to make changes. Even better, custom labels let you insert HTML code into the Rich Text component!

For example, here is a custom label that stores an HTML code to display a gif image.

Custom Label with HTML Code
<p style="text-align: center;">
<img src="https://salesforcetime.com/wp-content/uploads/2025/04/Visual-Picker.gif" alt="Logo" width="600"/>
</p>

Here is how you can add this HTML code (custom label) to Lightning page.

{!$Label.API_Name_of_the_custom_label}
Adding Custom Label to Lightning Page

At the end, Rich Text component will display the gif image on the Lightning page.

Displaying Image on Lightning Page

Using Custom Label to Open Links in a Rich Text Component in the Same Tab

Now, let's get back to the main topic: How can you open links in a Rich Text component in the same tab?

As you can see in this post, you simply need to use the "target" attribute in HTML.

Here’s a simple HTML example (using a custom label) to open a link in the same tab. In this example, the link opens a report in the same tab.

<a href="/00O1Q000008dvOlUAI" target="_self">Open Opportunities Report</a>
Custom Label to Open Links in a Rich Text Component in the Same Tab
Open Links in the Same Tab

Let's take it one step further and use SLDS to make the link look better. Read this post to learn how to display links as buttons.

Using SLDS
<a class="slds-button slds-button_brand" href="/00O1Q000008dvOlUAI" target="_self">Open Opportunities Report</a>
Display Links as Buttons

2 Comments

Leave a Reply

Your email address will not be published.


*