LWC is a new programming model leveraging recent web standards. This framework is quite powerful and allows developers to do customization with the best approach. Web Standards and Specialized services like Base Lightning Components, Lightning Data Service, and User Interface API allow in achieving the Modern Rich UI Implementations in Salesforce.
Previously used framework AURA was used for current Lightning Components and it was based on standards of 2014. These were are outdated now and it was time for change because for the following reasons:
- Rendering could be optimized.
- Standard UI elements were scarce.
- Lacked modern constructs.
- Was not fit for modular apps.
- Web standards were updated.
HTML and Javascript are the main contents of LWC. Whereas CSS is an optional content but then in addition to these for LWC, an XML configuration file is also included which defines the metadata values for the component.
Html
- Has a root tag <template> which contains your component’s HTML.
- When renders, the <template> tag is replaced with <namespace-component-name>.
Javascript
- The export statement allows other code to use functionality in a module.
- We extend LightningElement in the component and export, LightningElement is a custom wrapper of the standard HTML element.
Configuration
XML file that defines the metadata configuration values for the component eg-
- Components Label
- Availability
- Configuration Attributes
- Builder Attributes
CSS
- To style a component.
- The style sheet is applied automatically.