How to create Responsive Layouts Page Header, Footer, Left Sidebar, Right Sidebar & Main Body Container uses of lightning:layout & lightning:layoutItem Elements in Salesforce LWC | building a responsive layouts using lightning-layout, multiple-rows & lightning:layoutItem Elements in lightning web component Salesforce LWC

4,147 views

Hey guys, today in this post we are going to learn about How to create Responsive Layouts page Header, Footer, Left Sidebar, Right Sidebar & Main Body Container uses of lightning:layout & lightning:layoutItem Elements in Salesforce LWC.

A lightning-layout is a flexible grid system for arranging containers within a page or inside another container. The default layout is mobile-first and can be easily configured to work on different devices.

Create the content of the layout by including lightning-layout-item components within lightning-layout. You can place HTML tags and text between the lightning-layout-item components, but you can’t place other components or expressions between them. To know more details about lightning-layout, Click Here

Note:: – You will get an email, so put correct email and mobile number and BEGIN YOUR JOURNEY from Today!

 

Files we used to create lightning-layout page in LWC

lwcPageLayout.html LWc HTML File Template HTML file to create lightning layout page in lwc
lwcPageLayout.js LWC JavaScript File It’s hold a javascript Import and export function in lwc.
lwcPageLayout.js-meta.xml XML Meta File It is used to where this lightning web component file you want to display as like lightning__AppPage, lightning__RecordPage, lightning__HomePage.
lwcPageLayout.css Custom Style CSS It is used to fixed alignment of lightning layout page in lwc
lwcPageLayoutApp.app Lightning Application It is used for call the component to preview on browser.

Final Output

lwc creating responsive lightning layout page -- w3web.net

 

You can download file directly from github by Click Here.

 
 

Other related post that would you like to learn in Salesforce

  • Find the below steps

Create Lightning Web Component HTML

Step 1:- Create Lightning Web Component HTML ➡ lwcPageLayout.html

SFDX:Lightning Web Component ➡ New ➡ lwcPageLayout.html

Note:: – You will get an email, so put correct email and mobile number and BEGIN YOUR JOURNEY from Today!
 
 

lwcPageLayout.html [Lightning Web Component HTML]

  1.    <template>
  2. <div class="slds slds-p-around--large">   
  3. <div><a href="https://www.w3web.net/" target="_blank" rel="noopener noreferrer"><img src="https://www.salesforce.com/content/dam/sfdc-docs/www/logos/logo-salesforce.svg" width="auto" height="auto"/></a></div>
  4. <div class="c-container">
  5.     <lightning-layout multiple-rows="true">
  6.         <lightning-layout-item padding="around-small" size="12">
  7.             <div class="page-section page-header">
  8.                 <h2><strong style="color: #ff8000;">Header Section</strong></h2>
  9.             </div>
  10.         </lightning-layout-item>
  11.         <lightning-layout-item padding="around-small" size="12">
  12.             <lightning-layout>
  13.                 <lightning-layout-item padding="around-small" size="3">
  14.                     <div class="page-section page-right">
  15.                         <h2><strong style="color: #ff8000;">Left Sidebar</strong></h2>
  16.                         <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt
  17.                             ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation
  18.                             ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit
  19.                             in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
  20.                             cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
  21.                         </p>
  22.                     </div>
  23.                 </lightning-layout-item>
  24.                 <lightning-layout-item padding="around-small" size="6">
  25.                     <div class="page-section page-main">
  26.                         <h2><strong style="color: #ff8000;">Main Container</strong></h2>
  27.                         <p>Donec viverra pellentesque aliquet. Praesent quis tristique mauris, ac tincidunt ante.
  28.                             Nulla lectus nisi, tempor quis malesuada ac, consequat in velit. Nullam aliquam mauris eu magna
  29.                             dictum, in ornare risus convallis. Nunc condimentum ornare libero sit amet rhoncus. Aliquam tellus nisl,
  30.                             tristique sit amet congue in, tristique vel risus. Morbi leo ligula, blandit nec commodo at, pulvinar
  31.                             vitae libero. Mauris ipsum erat, aliquam a turpis vitae, faucibus viverra arcu. Donec id purus
  32.                             luctus enim elementum molestie sit amet ac libero.
  33.                         </p>
  34.                         <p>Mauris cursus felis elementum ipsum placerat, in maximus justo pretium. Nam nec sapien
  35.                             maximus justo feugiat tristique. Mauris viverra erat vitae arcu feugiat, sed posuere purus vulputate.
  36.                             Sed et nulla ut magna iaculis fringilla. Integer eget blandit elit. Phasellus nulla augue, lobortis a
  37.                             elementum tempus, auctor et felis. Fusce quis lorem tincidunt risus ullamcorper pharetra. Sed elit
  38.                             nulla, efficitur a lorem quis, mollis tristique elit. Etiam odio libero, ornare sed vehicula
  39.                             in, sagittis et erat. Integer at justo molestie, suscipit dui vel, scelerisque ex. Nulla non metus
  40.                             pulvinar, egestas neque et, tincidunt tellus. Praesent egestas scelerisque tristique. Nullam
  41.                             sodales ex acmetus tincidunt accumsan. Cras vitae consequat odio. Pellentesque facilisis lobortis
  42.                             lorem, at placerat mauris sagittis a.
  43.                         </p>
  44.                     </div>
  45.                 </lightning-layout-item>
  46.                 <lightning-layout-item padding="around-small" size="3">
  47.                     <div class="page-section page-right">
  48.                       <h2><strong style="color: #ff8000;">Right Sidebar</strong></h2>                        
  49.  
  50.                     <div class="slds-nav-vertical__section">                       
  51.                         <ul>                            
  52.                             <li class="slds-nav-vertical__item"><a class="slds-nav-vertical__action" href="https://www.w3web.net/" target="_blank" rel="noopener noreferrer">w3web Tutorial</a></li>
  53.                             <li class="slds-nav-vertical__item"><a class="slds-nav-vertical__action" href="https://www.w3web.net/tutorial/salesforce-integration/" target="_blank" rel="noopener noreferrer">Salesforce Integration</a></li>
  54.                             <li class="slds-nav-vertical__item"><a class="slds-nav-vertical__action" href="https://www.w3web.net/tutorial/salesforce-lwc/" target="_blank" rel="noopener noreferrer">Salesforce LWC</a></li>
  55.                             <li class="slds-nav-vertical__item"><a class="slds-nav-vertical__action" href="https://www.w3web.net/tutorial/lightning-component/" target="_blank" rel="noopener noreferrer">Salesforce Aura Component</a></li>
  56.                             <li class="slds-nav-vertical__item"><a class="slds-nav-vertical__action" href="https://www.w3web.net/tutorial/trigger/" target="_blank" rel="noopener noreferrer">Apex Trigger</a></li>
  57.                             <li class="slds-nav-vertical__item"><a class="slds-nav-vertical__action" href="https://www.w3web.net/tutorial/visualforce/" target="_blank" rel="noopener noreferrer">Visualforce</a></li>
  58.                             <li class="slds-nav-vertical__item"><a class="slds-nav-vertical__action" href="https://www.w3web.net/tutorial/jquery/" target="_blank" rel="noopener noreferrer">JQuery/Javascript</a></li>
  59.                             <li class="slds-nav-vertical__item"><a class="slds-nav-vertical__action" href="https://www.w3web.net/all-published-post/" target="_blank" rel="noopener noreferrer">Sitemap W3web</a></li>
  60.                             <li class="slds-nav-vertical__item"><a class="slds-nav-vertical__action" href="https://www.w3web.net/about-us/" target="_blank" rel="noopener noreferrer">About Us</a></li>
  61.                             <li class="slds-nav-vertical__item"><a class="slds-nav-vertical__action" href="https://www.w3web.net/contact-us/" target="_blank" rel="noopener noreferrer">Contact Us</a></li>
  62.                         </ul>
  63.                       </div>
  64.                     </div>
  65.                 </lightning-layout-item>
  66.             </lightning-layout>
  67.         </lightning-layout-item>
  68.         <lightning-layout-item flexibility="auto" padding="around-small" size="12">
  69.             <div class="page-footer page-section">
  70.                 <h2><strong style="color: #ff8000;">Footer</strong></h2>
  71.             </div>
  72.         </lightning-layout-item>
  73.     </lightning-layout>
  74. </div>
  75. <br/><br/>
  76.    <!--Start RelatedTopics Section-->
  77. <div style="border:1px #ddd solid; padding:10px; background:#eee; margin:40px 0;">
  78.  
  79.             <p data-aura-rendered-by="435:0"><img src="https://www.w3web.net/wp-content/uploads/2021/05/thumbsUpLike.png" width="25" height="25" style="vertical-align:top; margin-right:10px;" data-aura-rendered-by="436:0"><strong data-aura-rendered-by="437:0"><span style="font-size:16px; font-style:italic; display:inline-block; margin-right:5px;">Don't forget to check out:-</span><a href="https://www.w3web.net/" target="_blank" rel="noopener noreferrer" style="text-decoration:none;" data-aura-rendered-by="440:0">An easy way to learn step-by-step online free Salesforce tutorial, To know more Click  <span style="color:#ff8000; font-size:18px;" data-aura-rendered-by="442:0">Here..</span></a></strong></p>
  80.  
  81.             <br/><br/>
  82.             <p data-aura-rendered-by="435:0"><img src="https://www.w3web.net/wp-content/uploads/2021/07/tickMarkIcon.png" width="25" height="25" style="vertical-align:top; margin-right:10px;" data-aura-rendered-by="436:0"><strong data-aura-rendered-by="437:0"><span style="font-size:17px; font-style:italic; display:inline-block; margin-right:5px; color:rgb(255 128 0);">You May Also Like →</span> </strong></p>
  83.             <div style="display:block; overflow:hidden;"> 
  84.                 <div style="width: 50%; float:left; display:inline-block">
  85.                     <ul style="list-style-type: square; font-size: 16px; margin: 0 0 0 54px; padding: 0;"> 
  86.                         <li><a href="https://www.w3web.net/lwc-get-set-lightning-checkbox-value/" target="_blank" rel="noopener noreferrer">How to get selected checkbox value in lwc</a></li>
  87.                         <li><a href="https://www.w3web.net/display-account-related-contacts-in-lwc/" target="_blank" rel="noopener noreferrer">how to display account related contacts based on AccountId in lwc</a></li>
  88.                         <li><a href="https://www.w3web.net/create-lightning-datatable-row-actions-in-lwc/" target="_blank" rel="noopener noreferrer">how to create lightning datatable row actions in lwc</a></li>
  89.                         <li><a href="https://www.w3web.net/if-and-else-condition-in-lwc/" target="_blank" rel="noopener noreferrer">how to use if and else condition in lwc</a></li>
  90.                         <li><a href="https://www.w3web.net/get-selected-radio-button-value-and-checked-default-in-lwc/" target="_blank" rel="noopener noreferrer">how to display selected radio button value in lwc</a></li>
  91.                     </ul>
  92.             </div>
  93.  
  94.             <div style="width: 50%; float:left; display:inline-block">
  95.                     <ul style="list-style-type: square; font-size: 16px; margin: 0 0 0 54px; padding: 0;"> 
  96.                         <li><a href="https://www.w3web.net/display-account-related-contacts-lwc/" target="_blank" rel="noopener noreferrer">display account related contacts based on account name in lwc</a></li>
  97.                         <li><a href="https://www.w3web.net/create-lightning-datatable-row-actions-in-lwc/" target="_blank" rel="noopener noreferrer">how to insert a record of account Using apex class in LWC</a></li>
  98.                         <li><a href="https://www.w3web.net/fetch-picklist-values-dynamic-in-lwc/" target="_blank" rel="noopener noreferrer">how to get picklist values dynamically in lwc</a></li>
  99.                         <li><a href="https://www.w3web.net/edit-save-and-remove-rows-dynamically-in-lightning-component/" target="_blank" rel="noopener noreferrer">how to edit/save row dynamically in lightning component</a></li>
  100.                         <li><a href="https://www.w3web.net/update-parent-object-from-child/" target="_blank" rel="noopener noreferrer">update parent field from child using apex trigger</a></li>
  101.                     </ul>
  102.                 </div>
  103.                <div style="clear:both;"></div> 
  104.                <br/>
  105.                 <div class="youtubeIcon">
  106.                     <a href="https://www.youtube.com/channel/UCW62gTen2zniILj9xE6LmOg" target="_blank" rel="noopener noreferrer"><img src="https://www.w3web.net/wp-content/uploads/2021/11/youtubeIcon.png" width="25" height="25" style="vertical-align:top; margin-right:10px;"/> <strong>TechW3web:-</strong> To know more, Use this <span style="color: #ff8000; font-weight: bold;">Link</span> </a>
  107.                 </div>
  108.     </div>
  109.  
  110. </div>
  111.  
  112.   <!--End RelatedTopics Section-->    
  113. </div>  
  114. </template>

Create Lightning Web Component Javascript

Step 2:- Create Lightning Web Component Javascript ➡ lwcPageLayout.js

SFDX:Lightning Web Component ➡ New ➡ lwcPageLayout.js

lwcPageLayout.js [LWC JavaScript File]

  1.     import { LightningElement } from 'lwc';
  2.  
  3. export default class LwcPageLayout extends LightningElement {
  4.  
  5. }

Create Custom Style CSS

Step 3:- Create Custom Style CSS ➡ lwcPageLayout.css

SFDX:Lightning Web Component ➡ New ➡ lwcPageLayout.css

lwcPageLayout.css [LWC Custom Style CSS]

  1.    .c-container {
  2.     border: 1px solid #d8dde6;
  3.     margin: 10px 0 20px 0;
  4. }
  5. .page-section {
  6.     border: solid 1px #ccc;
  7.     padding: 1rem;
  8. }
  9. .page-header,
  10. .page-footer {
  11.     height: 50px;
  12. }
  13. .page-main {
  14.     background: #f8f8f8;
  15. }
  16. .page-left,
  17. .page-right {
  18.     background: #f0efef;
  19. }

Create Lightning Web Component Meta XML

Step 4:- Create Lightning Web Component Meta XML ➡ lwcPageLayout.js-meta.xml

SFDX:Lightning Web Component ➡ New >> lwcPageLayout.js-meta.xml

lwcPageLayout.js-meta.xml [LWC Meta Data XML]

  1.    <?xml version="1.0" encoding="UTF-8"?>
  2. <LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
  3.     <apiVersion>45.0</apiVersion>
  4.     <isExposed>true</isExposed>
  5.     <targets>
  6.         <target>lightning__AppPage</target>
  7.         <target>lightning__RecordPage</target>
  8.         <target>lightning__HomePage</target>
  9.       </targets>
  10. </LightningComponentBundle>

Create Lightning Application

Step 5:- Create Lightning Application : lwcPillsApp.app

From Developer Console >> File >> New >> Lightning Application

lwcPageLayoutApp.app [Component Application File]

  1.    <aura:application extends="force:slds">
  2.    <c:lwcPageLayout/>
  3. </aura:application>

lwc creating responsive lightning layout page -- w3web.net

Further post that would you like to learn in Salesforce

 

 

 

FAQ (Frequently Asked Questions)

What is lightning layout?

A lightning:layout is a flexible grid system for arranging containers within a page or inside another container.

What is the use of lightning layout in Salesforce?

lightning-layout enables you to create several types of columns. Create a simple layout by enclosing single or multiple lightning-layout-item components within lightning-layout .

What can be done using page layout?

Page layouts control the layout and organization of buttons, fields, s-controls, Visualforce, custom links, and related lists on object record pages.

Related Topics | You May Also Like

 
Note:: – You will get an email, so put correct email and mobile number and BEGIN YOUR JOURNEY from Today!
 
 
  

Our Free Courses →

👉 Get Free Course →

📌 Salesforce Administrators

📌 Salesforce Lightning Flow Builder

📌 Salesforce Record Trigger Flow Builder

👉 Get Free Course →

📌 Aura Lightning Framework

📌 Lightning Web Component (LWC)

📌 Rest APIs Integration



Hi, This is Vijay Kumar behind the admin and founder of w3web.net. I am a senior software developer and working in MNC company from more than 8 years. I am great fan of technology, configuration, customization & development. Apart of this, I love to write about Blogging in spare time, Working on Mobile & Web application development, Salesforce lightning, Salesforce LWC and Salesforce Integration development in full time. [Read full bio] | | The Sitemap where you can find all published post on w3web.net

Leave a Comment