Setting Attributes on a Component Reference

When you include another component, such as <lightning:button>, in a component, we call that a component reference to <lightning:button>. You can use <aura:set> to set an attribute on the component reference. For example, if your component includes a reference to <lightning:button>:

<lightning:button label="Save">
    <aura:set attribute="variant" value="brand"/>
</lightning:button>

This is equivalent to:

<lightning:button label="Save" variant="brand" />

The latter syntax without aura:set makes more sense in this simple example. You can also use this simpler syntax in component references to set values for attributes that are inherited from parent components.

aura:set is more useful when you want to set markup as the attribute value. For example, this sample specifies the markup for the else attribute in the aura:if tag.

<aura:component>
    <aura:attribute name="display" type="Boolean" default="true"/>
    <aura:if isTrue="{!v.display}">
        Show this if condition is true
        <aura:set attribute="else">
           <lightning:button label="Save" onclick="{!c.saveRecord}" />
        </aura:set>
    </aura:if>
</aura:component>