function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Hiu Tung SzetoHiu Tung Szeto 

Hi, how can I code for an aura lightning component to have the same layout in mobile as for web for a custom object?

Best Answer chosen by Hiu Tung Szeto
SubratSubrat (Salesforce Developers) 

Hello Hiu Tung ,

To ensure that your Aura lighning component has same layout as of Mobile you can follow certain specifications :

Use a Responsive Design : Responsive design enables your app page or website to scale elegantly across screen sizes. It uses fluid grids and media queries to display the right layout for different screens. Responsive design improves app maintainability and reliability, while future proofing for different browsers and platforms.

Reference : https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.mobile_layout


 You can use SLDS classes to create a responsive layout for a Lightning Component that displays a custom object:
 

<aura:component implements="flexipage:availableForAllPageTypes">
    <ltng:require styles="/resource/SLDS0123/assets/styles/salesforce-lightning-design-system-ltng.min.css"/>
    <div class="slds-grid slds-wrap">
        <div class="slds-col slds-size_1-of-2">
            <!-- Left column content here -->
        </div>
        <div class="slds-col slds-size_1-of-2">
            <!-- Right column content here -->
        </div>
    </div>
</aura:component>
Reference : https://www.lightningdesignsystem.com/


By using the slds-wrap class, the grid layout will wrap to the next row on smaller screens, creating a responsive layout that works well on mobile devices.

If it helps please mark this as Best Answer.
Thank you.

All Answers

SubratSubrat (Salesforce Developers) 

Hello Hiu Tung ,

To ensure that your Aura lighning component has same layout as of Mobile you can follow certain specifications :

Use a Responsive Design : Responsive design enables your app page or website to scale elegantly across screen sizes. It uses fluid grids and media queries to display the right layout for different screens. Responsive design improves app maintainability and reliability, while future proofing for different browsers and platforms.

Reference : https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.mobile_layout


 You can use SLDS classes to create a responsive layout for a Lightning Component that displays a custom object:
 

<aura:component implements="flexipage:availableForAllPageTypes">
    <ltng:require styles="/resource/SLDS0123/assets/styles/salesforce-lightning-design-system-ltng.min.css"/>
    <div class="slds-grid slds-wrap">
        <div class="slds-col slds-size_1-of-2">
            <!-- Left column content here -->
        </div>
        <div class="slds-col slds-size_1-of-2">
            <!-- Right column content here -->
        </div>
    </div>
</aura:component>
Reference : https://www.lightningdesignsystem.com/


By using the slds-wrap class, the grid layout will wrap to the next row on smaller screens, creating a responsive layout that works well on mobile devices.

If it helps please mark this as Best Answer.
Thank you.

This was selected as the best answer
Hiu Tung SzetoHiu Tung Szeto

Thanks this helped. However, the mobile page layout doesn't match what I see on the lightning page layout for phone. Is there a reason why this is happening?

  1. E.g. there is an additional field section that shouldn't be there (this field section doesn't show up under the lightning page layout for phone)
  2. E.g. under the details tab, nothing shows up on the mobile app even though under the lightning page layout, there are sections and fields for phone.
  3. E.g. I am unable to see one of the accordion sections on the mobile app, even though under the lightning page layout it appears for phone.