How to use the lightning-formatted-email, lightning-formatted-number, lightning-formatted-phone, lightning-formatted-date-time, lightning-formatted-text, lightning-formatted-address, lightning-formatted-url in Salesforce lightning web component (LWC) | how to display of lightning-formatted input fields and there values in Salesforce LWC (Lightning Web Component)

Vijayk
4 min readJan 20, 2022

Hey guys, today in this post we are going to learn about How to use the lightning-formatted-email, lightning-formatted-number, lightning-formatted-phone, lightning-formatted-date-time, lightning-formatted-text, lightning-formatted-address, lightning-formatted-url in Salesforce lightning web component (LWC).

A lightning-formatted-text component displays a read-only representation of text, and can convert URLs and email addresses to links, or “linkify” them. Click more about lightning-formatted-text.

A lightning-formatted-time component displays a read-only representation of time in the user’s locale format. A valid ISO8601 formatted time string must be used. To know more about lightning-formatted-time, Click Here.

A lightning-formatted-number component displays formatted numbers for decimals, currency, and percentages. Use format-style to specify the number style. This component uses the Intl.NumberFormat JavaScript object to format numerical values. Click here to know more about lightning-formatted-number.

A lightning-formatted-phone component displays a read-only representation of a phone number as a hyperlink using the tel: URL scheme. Clicking the phone number opens the default VOIP call application on a desktop. On mobile devices, clicking the phone number calls the number. To know more about lightning-formatted-phone, Click Here.

Files we used to create lightning-formatted in Salesforce LWC →

lwcFormattedInput.html

LWc HTML File

Template HTML file to display lightning formatted field’s value in Salesforce Lightning Web Component (LWC)

lwcFormattedInput.js

LWC JavaScript File

It’s hold import & export method in Salesforce LWC.

lwcFormattedInput.js-meta.xml

XML Meta File

It is used to where this lightning web component file you want to display as lightning__AppPage, lightning__RecordPage, lightning__HomePage.

Final Output → To get source code live demo, Click Here..

Other related post that would you like to learn in LWC

Create Lightning Web Component HTML →

Step 1:- Create Lightning Web Component HTML ➡ lwcFormattedInput.html

SFDX:Lightning Web Component ➡ New ➡ lwcFormattedInput.html

lwcFormattedInput.html [Lightning Web Component HTML]

<lightning-formatted-address

<lightning-formatted-address

Absolute URLs are created if the value doesn’t begin with /

Relative URLs are created if the value begins with /

Only http, https, and ftp protocols are supported.

Create Lightning Web Component Javascript →

Step 2:- Create Lightning Web Component Javascript ➡ lwcFormattedInput.js

SFDX:Lightning Web Component ➡ New ➡ lwcFormattedInput.js

lwcFormattedInput.js [LWC JavaScript File]

Create Lightning Web Component Meta XML →

Step 3:- Create Lightning Web Component Meta XML ➡ lwcFormattedInput.js-meta.xml

SFDX:Lightning Web Component ➡ New >> lwcFormattedInput.js-meta.xml

lwcFormattedInput.js-meta.xml [LWC Meta Data XML]

Lightning Web Component Meta XML

Further post that would you like to learn in LWC FAQ (Frequently Asked Questions)

What is lightning card in LWC?

A lightning-card is used to apply a stylized container around a grouping of information. The information could be a single item or a group of items such as a related list. Use the variant or class attributes to customize the styling.

Can we call lightning component from LWC?

Lightning web components can import methods from Apex classes into the JavaScript classes using ES6 import. Once after importing the apex class method you can able to call the apex methods as functions into the component by calling either via the wire service or imperatively.

What is variant in Lightning card?

Variants on a component refer to design variations for that component, which enable you to change the appearance of the component easily. … This example uses a Lightning Design System class to apply a padding to a paragraph in the lightning:card component.

Final Output → To get source code live demo, Click Here..

Hi, This is Vijay behind the admin and founder of w3web.net. I am a senior software developer and working in MNC company from more than 8 years. I am great fan of technology, configuration, customization & development. Apart of this, I love to write about Blogging in spare time, Working on Mobile & Web application development, Salesforce lightning, Salesforce LWC and Salesforce Integration development in full time. [Read full bio] | | The Sitemap where you can find all published post on w3web.net

Originally published at https://www.w3web.net on January 20, 2022.

--

--