Newer Version Available

This content describes an older version of this product. View Latest

Lightning Page Template Component Best Practices

Keep these best practices and limitations in mind when creating Lightning page template components.
  • Don’t add custom background styling to a template component. It interferes with Salesforce’s Lightning Experience page themes.
  • We strongly recommend including supported form factor information in the design file of all of your components. If you don’t, the component might behave in unexpected ways.
  • Template component supported form factors must be equal to, or a subset of, the supported form factors of its page type.
  • Once a component is in use on a Lightning page, you can only increase the supported form factors for the component, not decrease them.
  • Including scrolling regions in your template component can cause problems when you try to view it in the Lightning App Builder.
  • Custom templates can’t be extensible nor extended—you can’t extend a template from anything else, nor can you extend other things from a template.
  • Using getters to get the regions as variables works at design time but not at run time. Here’s an example of what we mean.
    1<aura:component implements="lightning:appHomeTemplate">
    2    <aura:attribute name="region" type="Aura.Component[]" />
    3    <aura:handler name="init" value="{!this}" action="{!c.init}" />
    4
    5    <div>
    6        {!v.region}
    7    </div>
    8    
    9</aura:component>
    1{
    2    init : function(component, event, helper) {
    3        var region = cmp.get('v.region'); // This will fail at run time.
    4        ...
    5    }
    6}
  • You can remove regions from a template if it’s not being used by a Lightning page, and if it’s not set to access=global. You can add regions at any time.
  • A region can be used more than once in the code, but only one instance of the region should render at run time.
  • A template component can contain up to 25 regions.
  • The order that you list the regions in a page template is the order that the regions appear in when admins migrate region content using the template switching wizard in the Lightning App Builder. We recommend that you label the regions and list them in a logical order in your template, such as top to bottom or left to right.