Skip to content
StackDecode
AdvancedLesson 24 of 37

Lightning Web Components

Modern UI built on web standards.

A component is a folder with HTML, JavaScript and optional CSS and a meta file.

html
<!-- hello.html -->
<template>
  <lightning-card title="Hello">
    <p class="slds-p-around_small">Hello, {name}! Clicks: {count}</p>
    <lightning-button label="Click" onclick="{handleClick}"></lightning-button>
  </lightning-card>
</template>
javascript
// hello.js
import { LightningElement, api } from 'lwc';
export default class Hello extends LightningElement {
  @api name = 'World'; // public property, set by a parent
  count = 0; // reactive
  handleClick() {
    this.count++;
  }
}

Use the Lightning Design System (SLDS) for styling and the base components (lightning-*) wherever possible. Expose a component to App Builder with a js-meta.xml file.