top of page

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.




bottom of page