Component
Expression
HTML
If
Iteration
Render If (Deprecated)
Template
Text
Unescaped HTML
LWC Developer Guide
SLDS 1
SLDS 2
aura:if
Conditionally instantiates and renders either the body or the components in the else attribute.
For Use In
Lightning Experience, Experience Builder Sites, Salesforce Mobile App, Lightning Out (Beta), Standalone Lightning App
aura:if evaluates the isTrue expression on the server and instantiates components in either its body or else attribute. Only one branch is created and rendered. Switching condition unrenders and destroys the current branch and generates the other.
1<aura:component>
2 <aura:if isTrue="{!v.truthy}">
3 True
4 <aura:set attribute="else">
5 False
6 </aura:set>
7 </aura:if>
8</aura:component>| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| body | The components to render when isTrue evaluates to true. | Aura.ComponentDefRef[] | ||
| else | The alternative to render when isTrue evaluates to false, and the body is not rendered. Should always be set using the aura:set tag. | Aura.ComponentDefRef[] | ||
| isTrue | An expression that must be fulfilled in order to display the body. | Boolean |