top of page
Writer's pictureSaurabh Singh

New conditional directive lwc:if, lwc:elseif, and lwc:else in Spring 23

The Spring 23 release of Salesforce introduced new conditional directives for Lightning Web Components (LWC) templates. These new directives are `lwc:if`, `lwc:elseif`, and `lwc:else`.


They supersede the legacy `if:true` and `if:false` directives.

To render HTML conditionally, we used to add the `if:true|false` directive to a nested `<template>` tag that encloses the conditional content. But with Spring 23 we can do Conditional Rendering in LWC using new `lwc:if`, `lwc:elseif` and `lwc:else`.


These new directives provide developers with more flexibility and control when building LWC templates.




2 Comments


Sridhar NareshIT
Sridhar NareshIT
Jul 28, 2023

Good information, Thanks for the updated information .

https://nareshit.in/salesforce-crm-training/

Like

Arpit Pathak
Arpit Pathak
Apr 09, 2023

Thank you for keeping us updated !

Like
bottom of page