Represents a responsive grid system for arranging containers on a page.
For Aura components only. For LWC development, use lightning-layout.
For Use In
Lightning Experience, Experience Builder Sites, Salesforce Mobile App, Lightning Out (Beta), Standalone Lightning App, Mobile Offline
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:layoutItem components within lightning:layout.
This component implements styling from the grid utility classes in the Lightning Design System.
Customize the layout by setting the following attribute values.
horizontalAlign
Spread layout items out horizontally based on the following values.
center: Appends the slds-grid_align-center class to the grid. This attribute orders the layout items into a horizontal line without any spacing, and places the group into the center of the container.
space: Appends the slds-grid_align-space class to the grid. The layout items are spaced horizontally across the container, starting and ending with a space.
spread: Appends the slds-grid_align-spread class to the grid. The layout items are spaced horizontally across the container, starting and ending with a layout item.
end: Appends the slds-grid_align-end class to the grid. The layout items are grouped together and aligned horizontally on the right side of the container.
verticalAlign
Spread layout items out vertically based on the following values.
start: Appends the slds-grid_vertical-align-start class to the grid. The layout items are aligned at the top of the container.
center: Appends the slds-grid_vertical-align-center class to the grid. The layout items are aligned in the center of the container.
end: Appends the slds-grid_vertical-align-end class to the grid. The layout items are aligned at the bottom of the container.
stretch: Appends the slds-grid_vertical-stretch class to the grid. The layout items extend vertically to fill the container.
pullToBoundary
Pull layout items to the layout boundaries based on the following values. If padding is used on layout items, this attribute pulls the elements on either side of the container to the boundary. Choose the size that corresponds to the padding on your layout items. For instance, if lightning:layoutItem padding="horizontalSmall", choose pullToBoundary="small".
small: Appends the slds-grid_pull-padded class to the grid.
medium: Appends the slds-grid_pull-padded-medium class to the grid.
large: Appends the slds-grid_pull-padded-large class to the grid.
Use the class or multipleRows attributes to customize the styling in other ways.
Creating Columns
lightning:layout enables you to create several types of columns.
Flexible widths that adjust based on their content
Fixed widths that take up a percentage of the container
Create a simple layout by enclosing single or multiple lightning:layoutItem components within lightning:layout. lightning:layoutItem creates a column within lightning:layout.
To create columns with widths that are based on their content, use flexibility="auto". The horizontalAlign attribute determines how to spread the layout items horizontally. For example, space evenly distributes columns horizontally with an equal amount of space separating the columns.
Here is an example that creates columns with flexible widths. The horizontal alignment is set to space, which evenly distributes columns horizontally with an equal amount of space separating the columns.
To create columns with fixed widths, use the size attribute on lightning:layoutItem. For example, to create two columns where the width of the first column is 33% of the grid container and the second column is 66% of the grid container, use size="4" and size="8".
A CSS class for the outer element, in addition to the component's base classes.
String
horizontalAlign
Determines how to spread the layout items horizontally. The alignment options are center, space, spread, and end.
String
multipleRows
Determines whether to wrap the child items when they exceed the layout width. If true, the items wrap to the following line. This value defaults to false.
Boolean
false
pullToBoundary
Pulls layout items to the layout boundaries and corresponds to the padding size on the layout item. Possible values are small, medium, or large.
String
title
Displays tooltip text when the mouse moves over the element.
String
verticalAlign
Determines how to spread the layout items vertically. The alignment options are start, center, end, and stretch.