Entry Customized Labels in Lightning Internet Element

Final Up to date on July 7, 2022 by Rakesh Gupta

Massive Concept or Enduring Query:

  • Learn how to use Customized Labels in Lightning Internet Parts?


After studying this weblog, you’ll be capable of:

  • Perceive the aim of customized label
  • Create customized labels and add translation to it
  • Import customized labels within the lightning net part
  • Entry customized labels within the lightning net part
  • and way more

Previously written just a few articles on Lightning Internet Element. Why not test them out while you’re at it?!

  1. Access Static Resources, Content Asset Files in Lightning Web Component
  2. Add Confirmation, Alert, and Prompt Dialog Box to Lightning Web Component

Rachel Gillett is working as a Junior Developer at Gurukul on Cloud (GoC). She has created a form utilizing the lightning net part (lwc) after studying this article, as proven beneath:

The fields label are arduous coded within the HTML file of the lightning net part.

	kind="e mail" 
	label="E mail Deal with" 

The Gross sales Director has requested her to make it possible for type labels ought to help a number of languages (primarily English, French, Spanish, and German). So, a person whose language belongs to certainly one of them should see labels of their native language.

What are Customized Labels?

Customized labels are customized textual content values that may be translated into any language that Salesforce helps. 

  • It’s also useful in offering one of the best in school person expertise by way of multilingual functions that mechanically current info in a person’s native language. 
  • It could include as much as 1000 characters.
  • Customized labels are accessible from Apex, Visualforce pages, Lightning Element, Lightning Internet Parts, and Salesforce Movement.

Create Customized Labels

Create one customized label to retailer the label for the E mail Deal with and its translation.

  1. Click on Setup.
  2. Within the Person Interface, kind Customized Labels.
  3. Click on on the New Customized Label button.
  4. Enter Quick Description; the Title will auto-populate.
  5. Now enter the E mail Deal with within the Worth.
  6. Click on Save.
  7. Add translation for german and french languages. 

Repeat the above steps to create one other customized label for Cell.

Learn how to Entry Customized Labels in Lightning Internet Element?

To entry customized labels in Lightning net parts first we now have to import from @salesforce/label to the part’s JavaScript file. 

import LabelName from '@salesforce/label/label-reference';

  • labelName – A reputation that refers back to the label.
  • labelReferenceThe title of the label in your org within the format namespace.labelName. 

Automation Champion Method (I-do):

Now it’s time to create a lightning net part to programmatically entry customized labels. 


A lightning net part can be utilized to construct customized pages for Lightning Expertise and the Salesforce cellular app rapidly with point-and-click instruments. Make certain so as to add the suitable goal for it.

This configuration file makes the part out there for all Lightning web page sorts however restricts help on desktops.

<?xml model="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://cleaning soap.sforce.com/2006/04/metadata">


To reference a useful resource in a template, use {property} syntax (i.e. {label.emailAddress} in our instance), which is identical syntax we use to reference any JavaScript property.

<!-- customLabelExample.html -->
            class="slds-p-top_small slds-p-bottom_medium slds-align_absolute-center slds-theme_default slds-text-heading_medium">
            <b>Customized Label Instance</b></div>
        <div class="slds-box slds-theme_default">
                    kind="e mail" 
            <div class="slds-m-top_small slds-align_absolute-center">


The JavaScript code imports two customized labels: one for E mail Deal with and one other for Cell. 

import { LightningElement } from 'lwc';
import emailAddress from '@salesforce/label/c.Email_Address';
import cellular from '@salesforce/label/c.Cell';

export default class InputExample extends LightningElement() {

     // Expose the labels to make use of within the template.
    label = {



Proof of Idea

Now, if a person whose language is about up as French views the shape, they’ll see the sphere’s label (E mail handle and Cell) of their native language.

Nice! You’re achieved! Be happy to change the lightning net part code to make use of the customized header and button labels.

Formative Evaluation:

I wish to hear from you!

What’s one factor you discovered from this submit? How do you envision making use of this new information in the actual world? Be happy to share within the feedback beneath.

Source link

Thanks for Reading

Enjoyed this post? Share it with your networks.

Leave a Feedback!