Lightning Components · June 28, 2023
How to Use lightning:layout and lightning:layoutItem
lightning:layout is a flexible grid system for arranging containers within a Salesforce Lightning page. It simplifies responsive design by replacing manual div grids with a mobile-first approach that adapts automatically across devices.
lightning:layout Attributes
horizontalAlignControls horizontal spacing of layout items.
verticalAlignManages vertical alignment of layout items.
pullToBoundaryPulls elements to container edges by applying negative margins.
multipleRowsWhen true, child elements wrap to the next line when exceeding layout width. Defaults to false.
lightning:layoutItem Attributes
lightning:layoutItem is the basic container element inside a layout. It controls sizing across device breakpoints.
sizeDivides the viewport into 12 columns. Values range from 1–12. A size of 6 takes up half the width.
smallDeviceSizeOverrides size for tablets and above.
mediumDeviceSizeOverrides size for larger tablets and above.
largeDeviceSizeOverrides size for desktop and above.
flexibilityControls how items absorb or shrink available space. Options: auto, shrink, grow, none.
paddingApplies spacing inside the layout item. Options: horizontal-small through around-large.
Responsive Grid Example
<lightning:layout multipleRows="true">
<lightning:layoutItem
size="12"
smallDeviceSize="6"
largeDeviceSize="4"
padding="around-small">
<!-- Content here -->
</lightning:layoutItem>
</lightning:layout>This creates a card that is full-width on mobile, half-width on tablet, and one-third on desktop — all without custom CSS.
Need help?
Get expert Salesforce development support
Our Lightning component developers build custom Salesforce UIs for enterprise clients. Book a free call to discuss your project.
Book a Free Call