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

How to Open Links in a Rich Text Component in the Same Tab
by: Yumi Ibrahimzade
blow post content copied from  Salesforce Time
click here to view original post



### Summary of the Content The Rich Text component in Salesforce Lightning pages allows users to add formatted text, images, and links easily. However, by default, links open in a new tab, and there is no built-in option to change this behavior. To open links in the same tab, users can utilize a workaround involving custom labels. Custom labels can be used to insert HTML code into the Rich Text component, allowing for greater control over the content displayed. For instance, you can create a custom label that contains HTML to display images or links. By using the "target" attribute in HTML, you can specify that a link should open in the same tab. ### Key Details: - **Rich Text Component**: Used for adding formatted content to Lightning pages. - **Default Behavior**: Links open in a new tab with no option to change this. - **Workaround**: Use custom labels to insert HTML and control link behavior. - **Example**: To open a link in the same tab, use `Link Text`. ### Additional Context This feature is particularly useful for Salesforce users who want to streamline navigation within their applications without overwhelming users with multiple tabs. Custom labels also help maintain consistency across multiple pages, making updates easier. ### Hashtags for SEO #Salesforce #LightningComponent #RichText #CustomLabels #WebDevelopment #HTML #UserExperience #SalesforceTips #SalesforceCustomization #LinkBehavior


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

The post How to Open Links in a Rich Text Component in the Same Tab appeared first on Salesforce Time.


April 27, 2025 at 04:42PM
Click here for more details...

=============================
The original post is available in Salesforce Time by Yumi Ibrahimzade
this post has been published as it is through automation. Automation script brings all the top bloggers post under a single umbrella.
The purpose of this blog, Follow the top Salesforce bloggers and collect all blogs in a single place through automation.
============================

Salesforce