Monday, July 6, 2026

lwc - Paginated Data Table

📋 Paginated Data Table – Reusable Salesforce LWC

A reusable Lightning Web Component built on lightning-datatable that adds server-side sorting, pagination controls, row selection, loading states, and complete backend independence.

📖 Project Overview

Paginated Data Table is a fully controlled Salesforce Lightning Web Component that extends the standard lightning-datatable with enterprise-ready pagination and sorting capabilities.

Unlike traditional datatable implementations, this component never performs data retrieval itself. Instead, it simply renders the current page of data and communicates user actions back to the parent component using custom events. This makes it reusable with Apex, REST APIs, GraphQL services, wired adapters, or even static datasets.

The repository also includes a complete demo implementation powered by Apex using secure SOQL queries with WITH SECURITY_ENFORCED.

✨ Features

Feature Description
Server-side SortingFires sort events instead of sorting locally, allowing Apex or external services to perform sorting.
Pagination ControlsFirst, Previous, Next, Last navigation with configurable page size.
Row SelectionSupports standard lightning-datatable row selection events.
Row ActionsFully compatible with Edit, Delete and custom row action menus.
Loading StateBuilt-in spinner overlay while data is loading.
Error HandlingDisplays configurable error banners for backend failures.
Empty StateShows custom messages when no records are available.
Imperative APIProvides getSelectedRows() for parent components.
Backend AgnosticWorks with Apex, REST APIs, GraphQL or static arrays.

🏗 Component Architecture

Salesforce-Paginated-Data-Table-Reusable

📁 Project Structure

force-app
│
├── classes
│   ├── PaginatedTableController.cls
│   └── PaginatedTableControllerTest.cls
│
├── lwc
│   ├── paginatedDataTable
│   └── paginatedDataTableDemo
│
└── README.md

⚙️ Public API

Property Purpose
columnsColumn configuration for the datatable.
dataCurrent page records.
totalRecordsTotal number of available records.
pageSizeRecords displayed per page.
currentPageCurrent active page.
sortedByCurrent sorted field.
sortedDirectionAscending or Descending order.
isLoadingDisplays loading spinner.

🔄 User Workflow

Load Page
    │
    ▼
Parent Fetches Records
    │
    ▼
Render Current Page
    │
    ▼
User Sorts Column
    │
    ▼
Sort Event Fired
    │
    ▼
Parent Retrieves Data
    │
    ▼
Refresh Table

📡 Supported Events

  • sort — User changes column sorting.
  • pagechange — User navigates between pages.
  • rowselection — Selected rows change.
  • rowaction — Standard row actions.

🎯 Business Use Cases

  • Large Contact Lists
  • Opportunity Management
  • Account Dashboards
  • Service Case Management
  • Lead Administration
  • Experience Cloud Data Tables
  • External REST Data
  • Enterprise Reporting Dashboards

🔒 Security

  • Supports Salesforce CRUD/FLS.
  • Uses WITH SECURITY_ENFORCED in Apex demo.
  • Backend-independent architecture.
  • Compatible with enterprise security best practices.

🚀 Deployment

sf org login web --alias my-org

sf project deploy start \
--source-dir force-app \
--target-org my-org

sf apex run test \
--class-names PaginatedTableControllerTest

📌 Conclusion

Paginated Data Table is a lightweight, reusable, and enterprise-ready Lightning Web Component that extends the standard Salesforce datatable with server-side pagination, sorting, row selection, and configurable states. By separating presentation from data retrieval, it can be seamlessly integrated with Apex controllers, REST services, GraphQL APIs, or any custom backend while remaining highly reusable across Salesforce applications.

Saturday, July 4, 2026

LWC: Reusable Dynamic Tabs

🗂️ Dynamic Tabs – Reusable Salesforce LWC Component

A production-ready Lightning Web Component that delivers fully accessible, highly configurable dynamic tabs with lazy loading, badge counts, SLDS icons, keyboard navigation, and closeable tabs—all built using native Salesforce Lightning Web Components.

📖 Project Overview

Dynamic Tabs is a reusable Lightning Web Component designed for modern Salesforce applications that require rich tabbed navigation while maintaining excellent performance and accessibility.

Unlike traditional tab implementations that render every panel immediately, this component supports lazy loading, meaning tab content is rendered only when a user opens it for the first time. After the initial load, content is simply shown or hidden without unnecessary re-rendering.

The component also includes badge counters, SLDS icons, closeable tabs, multiple layout variants, keyboard accessibility, and a clean public API that makes it easy to integrate into enterprise Salesforce applications.

✨ Features

Feature Description
Lazy LoadingTab content loads only when activated for the first time.
Badge CountsDisplays per-tab counters with automatic 99+ overflow handling.
SLDS IconsSupports any Salesforce Lightning icon beside the tab label.
Closeable TabsOptional close button with custom tabclose event.
Keyboard NavigationSupports Left, Right, Home and End keyboard shortcuts.
AccessibilityARIA-compliant implementation using tablist, tab and tabpanel roles.
Multiple VariantsSupports Default, Scoped and Vertical SLDS tab layouts.
Programmatic APISwitch tabs and update badge counts directly from JavaScript.
Reusable DesignCan be embedded into any Lightning page or custom component.

🏗 Component Architecture

LWC Reusable Dynamic Tabs

📁 Project Structure

force-app/
└── main/
    └── default/
        └── lwc/
            ├── dynamicTabs/
            │   ├── dynamicTabs.html
            │   ├── dynamicTabs.js
            │   ├── dynamicTabs.css
            │   └── dynamicTabs.js-meta.xml
            │
            ├── dynamicTabPanel/
            │   ├── dynamicTabPanel.html
            │   ├── dynamicTabPanel.js
            │   └── dynamicTabPanel.css
            │
            └── dynamicTabsDemo/

⚙️ Public API

Property / Method Purpose
variantChoose default, scoped, or vertical layout.
defaultTabAutomatically activate a tab on initial render.
switchTab()Programmatically activate any tab.
updateBadge()Update badge counts dynamically.
activeTabReturns the currently active tab.

🔄 Component Workflow

Page Loads
     │
     ▼
Render Tab Navigation
     │
     ▼
Activate Default Tab
     │
     ▼
Lazy Load Panel
     │
     ▼
User Switches Tabs
     │
     ▼
Previously Loaded?
     │
 ┌───┴────┐
 │        │
Yes      No
 │        │
 ▼        ▼
Show     Render Once
Content   Then Cache

⌨️ Keyboard Accessibility

  • ← Move to previous tab
  • → Move to next tab
  • Home jumps to the first tab
  • End jumps to the last tab
  • Fully ARIA-compliant tab navigation
  • Screen reader friendly implementation

🎨 Supported Variants

Variant Description
DefaultStandard Salesforce horizontal tabs.
ScopedSLDS scoped tab style.
VerticalVertical navigation for dashboards and setup pages.

🚀 Deployment

sf org login web --alias myOrg

sf project deploy start \
--source-dir force-app \
--target-org myOrg

🎯 Business Use Cases

  • Account & Contact workspaces
  • Customer Service Consoles
  • Sales dashboards
  • Experience Cloud portals
  • Admin configuration pages
  • Record detail workspaces
  • Multi-step business applications
  • Reusable enterprise component libraries

📌 Conclusion

The Dynamic Tabs component provides a powerful, enterprise-ready tab navigation experience for Salesforce applications. With lazy loading, badge counters, SLDS integration, keyboard accessibility, multiple layout variants, and a clean programmatic API, it enables developers to build scalable, high-performance Lightning applications while delivering an excellent user experience.

Thursday, July 2, 2026

LWC: Reusable Horizontal Bar Chart

📊 Reusable Horizontal Bar Chart for Salesforce LWC

A modern, reusable Lightning Web Component that renders responsive horizontal bar charts with smooth animations, adaptive labels, click-to-filter functionality, and zero third-party JavaScript libraries.

📖 Project Overview

horizontalBarChart is a fully reusable Salesforce Lightning Web Component designed for dashboards, Home Pages, App Pages, and Experience Cloud sites.

The component accepts a simple collection of { id, label, value } objects and automatically renders an attractive horizontal bar chart using native HTML, CSS and Lightning Web Components.

Built without Chart.js, D3.js, or any external dependency, the component offers excellent performance, smooth animations, accessibility, responsive layouts, configurable colors, interactive filtering, and App Builder support.

✨ Features

Feature Description
Animated EntryBars animate smoothly from 0% to their calculated width whenever data changes.
Adaptive LabelsAutomatically positions values inside or outside the bar based on available space.
Click-to-FilterClicking a bar selects it and fires a custom barclick event.
Toggle SelectionClick again to remove the active filter.
Clear Filter ButtonDisplays automatically whenever a filter is active.
External SelectionParent components can control selection using the selectedId property.
Automatic ScalingCalculates maximum value automatically or accepts a custom maxValue.
Large Number FormattingFormats values such as 45K, 1.2M, etc.
Custom ColorsSupports reusable color palettes that cycle automatically.
Legend SupportOptional color legend for dashboard visualization.
Responsive LayoutOptimized for desktop, tablet and mobile devices.
AccessibilityKeyboard navigation, ARIA labels and screen-reader support.

🏗 Component Architecture

Reusable Horizontal Bar Chart

📁 Project Structure

horizontalBarChart/
│
├── horizontalBarChart.html
├── horizontalBarChart.js
├── horizontalBarChart.css
├── horizontalBarChart.js-meta.xml
└── README.md

⚙️ Public API

Property Purpose
dataArray of { id, label, value } objects.
selectedIdExternally control selected bar.
maxValueOverride automatic scaling.
showLegendShow or hide legend.
colorsCustom color palette.

📦 Expected Data Structure

[
  {
    id: "A",
    label: "Prospecting",
    value: 120
  },
  {
    id: "B",
    label: "Qualification",
    value: 85
  },
  {
    id: "C",
    label: "Closed Won",
    value: 42
  }
]

🔄 Event Flow

Load Data
    │
    ▼
Calculate Maximum
    │
    ▼
Render Horizontal Bars
    │
    ▼
Animate Width
    │
    ▼
User Clicks Bar
    │
    ▼
Dispatch "barclick"
    │
    ▼
Parent Dashboard Filters

🎨 Styling Features

  • Salesforce Lightning Design System (SLDS) styling.
  • Uses Lightning Design Tokens.
  • Responsive layout.
  • Animated transitions.
  • Adaptive value labels.
  • Optional legend.
  • Empty state illustration.
  • Theme-friendly custom CSS variables.

♿ Accessibility

  • Keyboard accessible.
  • ARIA-compliant buttons.
  • Screen reader labels.
  • role="button" support.
  • aria-pressed state management.
  • Focus indicators.

🚀 Deployment

sf org login web --alias myOrg

sf project deploy start \
--source-dir force-app \
--target-org myOrg

🎯 Ideal Business Use Cases

  • Opportunity Stage Dashboard
  • Lead Source Analytics
  • Case Status Distribution
  • Revenue Comparison
  • Sales Team Performance
  • Service Metrics
  • Executive KPI Dashboards
  • Experience Cloud Analytics
  • Marketing Campaign Performance
  • Custom Salesforce Reports

📌 Conclusion

The Horizontal Bar Chart component provides an elegant, lightweight, and highly reusable solution for visualizing Salesforce data. Built entirely with Lightning Web Components and native web technologies, it offers smooth animations, adaptive labels, interactive filtering, responsive layouts, accessibility support, and App Builder compatibility—making it an excellent choice for modern Salesforce dashboards and analytics applications.