Skip to main content


Welcome to Daily Updates

*** Happy Learning***

Quick Links


==> Online Fun Games hub

==>Daily Job Updates IT and Non IT

==>Every month Current Affairs

==>Every month Dividend, Bonus Issue and Stock Split information

==> JAVASCRIPT QUIZ

==>AADHAAR download, Date of birth,name and Address correction, PVC card and more links

==> MICROSOFT EXCEL TUTORIAL

==> SQL Editor - For Practice

Salesforce LWC Tutorial: Components, Examples & Best Practices

The LWC Field Guide — Salesforce Components, Clearly Explained

A FIELD GUIDE FOR BUILDERS

Salesforce LWC,
without the mystery.

A friendly, code-first guide to Lightning Web Components. Learn what they are, when to use them, and how HTML, CSS, and JavaScript come together to build Salesforce experiences.

Made for curious developers
and Salesforce newcomers.

COMPONENT ANATOMY
contactCard READY
H contactCard.html structure
JS contactCard.js behavior
# contactCard.css appearance
01 <template> 02   <lightning-card 03     title="Hello, Salesforce"> 04     ...your UI goes here 05   </lightning-card> 06 </template>
⌘ Reusable by design
✦ Styles stay scoped
THE SHORT VERSION

LWC is a way to build custom, reusable interface pieces that run inside Salesforce.

↓
01 — START HERE

FIRST, THE HUMAN VERSION

Think of a component
like a well-designed room.

A room has a layout, a look, and things that happen inside it. An LWC does too. It is a small, self-contained part of a Salesforce page—such as a contact card, search form, or task dashboard.

The useful part? You can build a component once, then reuse it wherever that experience belongs. Salesforce provides ready-made components, and you can combine them with components of your own.

01
</>

HTML gives it structure.

Define what appears on screen: headings, fields, buttons, and Salesforce base components.

THE SKELETON
02
✳

CSS gives it a feel.

Set spacing, typography, and layout. LWC component styles are scoped to that component.

THE PERSONALITY
03
{ }

JavaScript makes it work.

Handle clicks, manage state, filter data, and connect the interface to Salesforce.

THE ENGINE
02 — THE TOOLBOX

SALESFORCE BASE COMPONENTS

Start with the building blocks.

These commonly used components save time and provide familiar Salesforce behavior. Search by name or by what you want to do.

/
01
LAYOUT

Give the page a clear structure.

Use cards to group content, layouts to create responsive columns, and tabs or accordions to organize details.

lightning-cardlightning-layoutlightning-accordionlightning-tabset
HTML EXAMPLE
<lightning-card title="Account overview">
    <lightning-layout multiple-rows>
        <lightning-layout-item
            size="12" medium-device-size="6">
            <p>Company details</p>
        </lightning-layout-item>
    </lightning-layout>
</lightning-card>
02
INPUT

Collect information with less friction.

Choose an input for the data type. Give every field a label, and handle its change event in JavaScript.

lightning-inputlightning-comboboxlightning-textarealightning-checkbox-group
HTML EXAMPLE
<lightning-input
    label="Contact name"
    value={contactName}
    onchange={handleNameChange}>
</lightning-input>

<lightning-combobox
    label="Status"
    value={status}
    options={statusOptions}
    onchange={handleStatusChange}>
</lightning-combobox>
03
ACTIONS

Make the next step obvious.

Use button variants to communicate emphasis, then connect a click to a JavaScript handler.

lightning-buttonlightning-button-iconlightning-button-menu
HTML EXAMPLE
<lightning-button
    label="Save changes"
    variant="brand"
    onclick={handleSave}>
</lightning-button>

<lightning-button-icon
    icon-name="utility:edit"
    alternative-text="Edit record">
</lightning-button-icon>
04
DATA

Make records easier to scan.

Display rows with a datatable, show hierarchy with a tree grid, or format values for people—not machines.

lightning-datatablelightning-tree-gridlightning-formatted-numberlightning-badge
HTML EXAMPLE
<lightning-datatable
    key-field="id"
    data={contacts}
    columns={columns}
    hide-checkbox-column>
</lightning-datatable>

<lightning-formatted-number
    value={revenue}
    format-style="currency">
</lightning-formatted-number>
05
FEEDBACK

Don’t leave users guessing.

Show when work is happening. Explain unfamiliar fields. Confirm success—or clearly describe what went wrong.

lightning-spinnerlightning-helptextShowToastEvent
HTML + JAVASCRIPT
<lightning-spinner
    alternative-text="Loading contacts"
    size="medium">
</lightning-spinner>

// In your component JavaScript:
this.dispatchEvent(new ShowToastEvent({
    title: 'Saved',
    message: 'Your changes are ready.',
    variant: 'success'
}));
06
NAVIGATION

Help people understand where they are.

Breadcrumbs show a path through content. Salesforce navigation APIs can take users to records and pages.

lightning-breadcrumbslightning-navigation
HTML EXAMPLE
<lightning-breadcrumbs>
    <lightning-breadcrumb
        label="Accounts"
        href="/lightning/o/Account/list">
    </lightning-breadcrumb>
    <lightning-breadcrumb label="Northstar">
    </lightning-breadcrumb>
</lightning-breadcrumbs>
07
YOUR OWN COMPONENTS

Make a building block that’s yours.

A parent can pass information down to a child. A child can announce an event back up. That’s how components work together.

<c-contact-card>@apiCustomEvent
HTML + JAVASCRIPT
<!-- Parent template -->
<c-contact-card
    contact={selectedContact}
    onselect={handleSelect}>
</c-contact-card>

// Child JavaScript:
this.dispatchEvent(new CustomEvent('select', {
    detail: this.contact.Id
}));
08
SALESFORCE DATA

Connect the interface to real records.

Use Lightning Data Service and wire adapters for supported Salesforce data. Use Apex when your use case needs server-side logic.

lightning-record-view-formlightning-record-edit-form@wire
HTML EXAMPLE
<lightning-record-view-form
    record-id={recordId}
    object-api-name="Account">
    <lightning-output-field
        field-name="Name">
    </lightning-output-field>
    <lightning-output-field
        field-name="Industry">
    </lightning-output-field>
</lightning-record-view-form>

Looking for every available component? Salesforce’s catalog is extensive and evolves with releases. Use the official Lightning Component Reference for the complete, current list and supported attributes.

03 — UNDER THE HOOD

HOW AN LWC IS PUT TOGETHER

One component.
Three files with clear jobs.

An LWC usually lives in its own folder. The folder name becomes the component’s name, and the files inside define how it renders, behaves, and becomes available in Salesforce.

H contactCard.htmlTemplate / structure ↗
JS contactCard.jsState / behavior ↗
# contactCard.cssScoped styling ↗
M contactCard.js-meta.xmlSalesforce configuration ↗

THE IMPORTANT IDEA

Each file has one job.

Keep the template focused on what users see. Keep JavaScript focused on state and behavior. Keep the component stylesheet focused on its own appearance.

✓

Clearer to understand
Another developer can find the right place to make a change.

✓

Easier to reuse
A component can be placed in supported Salesforce pages.

✓

Safer styling
Component CSS is scoped, so it is less likely to affect unrelated page content.

01 / REACTIVITY

Change state. Update the view.

When a component’s tracked values change, LWC can render the updated template. Use getters to prepare display values.

get hasContacts() {
    return this.contacts.length > 0;
}
02 / DATA FLOW

Pass data down. Send events up.

Public properties let a parent configure a child. Custom events let a child report something the parent should handle.

@api contact;

this.dispatchEvent(
    new CustomEvent('select', {
        detail: this.contact.Id
    })
);
03 / CSS ISOLATION

Style your component, not the app.

Use local class names, design tokens, and supported styling hooks. Avoid depending on the internal markup of base components.

:host {
    display: block;
    --accent: #0b8278;
}

.contact-card {
    border-radius: 1rem;
}
04 — YOUR FIRST BUILD

A SIMPLE WORKING SHAPE

Meet the helloCard.

This small example has a title, a message, and a button. It demonstrates a template, component state, an event handler, scoped CSS, and page configuration.

Where does the component go? In Salesforce, the metadata file controls where the component can be used. Add supported targets, deploy the component to your org, then place it on a Lightning page with Lightning App Builder.

05 — BUILD LIKE A PRO

THE POLISH IS IN THE DETAILS

Good components are
thoughtful components.

A professional interface does more than look polished. It helps people understand what is happening and what to do next.

01

Design every state

Plan for loading, empty results, success, and errors—not just the happy path.

02

Respect accessibility

Use labels, meaningful alternative text, keyboard-friendly controls, and clear feedback.

03

Use the right data tool

Choose Lightning Data Service or wire adapters when they fit; use Apex for server-side logic when needed.

04

Keep permissions in mind

Client-side code is not a security boundary. Protect records and actions with Salesforce permissions and secure server-side patterns.

05

Check the small screen

Make sure layouts, tables, and actions remain usable at narrow widths and with keyboard navigation.

THE TAKEAWAY

Start small.
Make it useful.

Pick one user problem. Compose Salesforce base components where they fit. Add your own HTML, scoped CSS, and JavaScript where your experience needs something more. That’s the heart of building with LWC.

Back to the beginning

Comments

Popular posts from this blog

JNTUK R16 SGPA and CGPA calculator for Lateral entry b.tech

Lateral entry students those are joined directly engineering by completing polytechnic, they may or may not appeared for ECET for getting seat in engineering course. that is B.Tech students studied course in 4 years but lateral entry students studied course is 3 years, that one year spend in polytechnic course. Lateral entry students strong in Technically than regular students. for SGPA calculator -   click here NOTE: IF ANYONE WANT CALCULATE UPTO SOME SEMISTERS(LIKE UPTO 3-2) FOR PLACEMENTS CAN PROVIDE REMAINING SGPAS AND TOTAL CREDITS AS ZEROS(0) THEN WILL GET ACCURATE CGPA TILL THAT PARTICULAR SEMISTER. FOR LATERAL ENTRY SCHEME B.TECH CGPA IS... FIRST SEMISTER SGPA    total credits   SECOND SEMISTER SGPA    total credits   THIRD SEMISTER SGPA    total credits   FOURTH SEMISTER SGPA    total credits  ...

JNTUK Convocation VIII for 2018-19 and 2019-20 batch OD apply

JNTUK Convocation VIII for 2018-19 and 2019-20 batch, who have taken the PC in the period of 01/01/2019 to 31/12/2020 For more details Click here last Date to apply - 18-12-2021 Required Documents: 1. PC 2. CMM (For UG ) 3. SSC 4. Recent Photo  5. For PG courses - Sem wise mark sheets 6. Adhaar front and back scanned copy 7. Bank challan or Payment - Those made offline payment should submit hard copies of above documents at the university examination Fee - Rs.2000/- Process to apply: 1. Register with Hall ticket number and email Id(user name) - Click here 2. Login with user name(E-mail ID) and password - click here 3. Enter the details and next step will be payment  Note: Updation of payment status into complete status may take 2-3 days 4. Then need to attach the required documents 5. Next step is to check the details and everything and then click on check box by agreeing that there information was furnished by you is true. 6. There will be no Submit option that is only downlo...

JNTUK R16, R19 SGPA CALCULATOR

JNTUK R16, R19 SGPA calculator, it is calculated as the sum of multiple of grade point with credit and then division with sum of credits to that semister. SGPA gives the marks in points out of 10 in the particular semister. Grade - Grade points 1. O - 10 2. S - 9 3. A - 8 4. B - 7 5. C - 6 6. D - 5 7. F - FAIL NOTE: IF ANY SEMISTER HAVE LESS THAN 9 SUBJECTS THEN PLACE ZEROS REMAINING BOXES IN GARDE POINT AS WELL AS CREDT BOX PLACE ZEROS. ACCURATE SGPA WILL COME. CALCULATE SGPA : FIRST SUBJECT Grade points    Credits   SECOND SUBJECT Grade points    credits   THIRD SUBJECT Grade points     credits   FOURTH SUBJECT Grade points    credits   FIFTH SUBJECT Grade points    credits   SIXTH SUBJECT Grade points    credits   SEVENTH SUBJECT Grade points     c...