<!--
{
  "documentType" : "article",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View-Layout",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Layout modifiers"
}
-->

# Layout modifiers

Tell a view how to arrange itself within a view hierarchy by adjusting its size,
position, alignment, padding, and so on.

## Overview

Use layout modifiers to fine tune the placement of views in a view hierarchy.
You can adjust or constrain the size, position, and alignment of a view. You
can also add padding around a view, and indicate how the view interacts
with system-defined safe areas.

To get started arranging views, see [Layout fundamentals](/documentation/SwiftUI/Layout-fundamentals).
To make adjustments to a basic layout, see [Layout adjustments](/documentation/SwiftUI/Layout-adjustments).

## Topics

### Size

[`frame(width:height:alignment:)`](/documentation/SwiftUI/View/frame(width:height:alignment:))

Positions this view within an invisible frame with the specified size.

[`frame(depth:alignment:)`](/documentation/SwiftUI/View/frame(depth:alignment:))

Positions this view within an invisible frame with the specified depth.

[`frame(minWidth:idealWidth:maxWidth:minHeight:idealHeight:maxHeight:alignment:)`](/documentation/SwiftUI/View/frame(minWidth:idealWidth:maxWidth:minHeight:idealHeight:maxHeight:alignment:))

Positions this view within an invisible frame having the specified size
constraints.

[`frame(minDepth:idealDepth:maxDepth:alignment:)`](/documentation/SwiftUI/View/frame(minDepth:idealDepth:maxDepth:alignment:))

Positions this view within an invisible frame having the specified depth
constraints.

[`containerRelativeFrame(_:alignment:)`](/documentation/SwiftUI/View/containerRelativeFrame(_:alignment:))

Positions this view within an invisible frame with a size relative
to the nearest container.

[`containerRelativeFrame(_:alignment:_:)`](/documentation/SwiftUI/View/containerRelativeFrame(_:alignment:_:))

Positions this view within an invisible frame with a size relative
to the nearest container.

[`containerRelativeFrame(_:count:span:spacing:alignment:)`](/documentation/SwiftUI/View/containerRelativeFrame(_:count:span:spacing:alignment:))

Positions this view within an invisible frame with a size relative
to the nearest container.

[`fixedSize()`](/documentation/SwiftUI/View/fixedSize())

Fixes this view at its ideal size.

[`fixedSize(horizontal:vertical:)`](/documentation/SwiftUI/View/fixedSize(horizontal:vertical:))

Fixes this view at its ideal size in the specified dimensions.

[`layoutPriority(_:)`](/documentation/SwiftUI/View/layoutPriority(_:))

Sets the priority by which a parent layout should apportion space to
this child.

[`containerCornerOffset(_:sizeToFit:)`](/documentation/SwiftUI/View/containerCornerOffset(_:sizeToFit:))

Adjusts the view’s layout to avoid the container view’s corner insets
for the specified edges.

### Position

[`position(_:)`](/documentation/SwiftUI/View/position(_:))

Positions the center of this view at the specified point in its parent’s
coordinate space.

[`position(x:y:)`](/documentation/SwiftUI/View/position(x:y:))

Positions the center of this view at the specified coordinates in its
parent’s coordinate space.

[`offset(_:)`](/documentation/SwiftUI/View/offset(_:))

Offset this view by the horizontal and vertical amount specified in the
offset parameter.

[`offset(x:y:)`](/documentation/SwiftUI/View/offset(x:y:))

Offset this view by the specified horizontal and vertical distances.

[`offset(z:)`](/documentation/SwiftUI/View/offset(z:))

Brings a view forward in Z by the provided distance in points.

[`coordinateSpace(_:)`](/documentation/SwiftUI/View/coordinateSpace(_:))

Assigns a name to the view’s coordinate space, so other code can operate
on dimensions like points and sizes relative to the named space.

### Alignment

[`alignmentGuide(_:computeValue:)`](/documentation/SwiftUI/View/alignmentGuide(_:computeValue:))

Sets the view’s horizontal alignment.

### Padding and spacing

[`padding(_:)`](/documentation/SwiftUI/View/padding(_:))

Adds a different padding amount to each edge of this view.

[`padding(_:_:)`](/documentation/SwiftUI/View/padding(_:_:))

Adds an equal padding amount to specific edges of this view.

[`padding3D(_:)`](/documentation/SwiftUI/View/padding3D(_:))

Pads this view using the edge insets you specify.

[`padding3D(_:_:)`](/documentation/SwiftUI/View/padding3D(_:_:))

Pads this view using the edge insets you specify.

[`listRowInsets(_:)`](/documentation/SwiftUI/View/listRowInsets(_:))

Applies an inset to the rows in a list.

[`listRowInsets(_:_:)`](/documentation/SwiftUI/View/listRowInsets(_:_:))

Sets the insets of rows in a list on the specified edges.

[`scenePadding(_:)`](/documentation/SwiftUI/View/scenePadding(_:))

Adds padding to the specified edges of this view using an amount that’s
appropriate for the current scene.

[`scenePadding(_:edges:)`](/documentation/SwiftUI/View/scenePadding(_:edges:))

Adds a specified kind of padding to the specified edges of this view
using an amount that’s appropriate for the current scene.

[`listRowSpacing(_:)`](/documentation/SwiftUI/View/listRowSpacing(_:))

Sets the vertical spacing between two adjacent rows in a List.

[`listSectionSpacing(_:)`](/documentation/SwiftUI/View/listSectionSpacing(_:))

Sets the spacing between adjacent sections in a [`List`](/documentation/SwiftUI/List) to a custom
value.

[`listSectionMargins(_:_:)`](/documentation/SwiftUI/View/listSectionMargins(_:_:))

Set the section margins for the specific edges.

### Grid configuration

[`gridCellColumns(_:)`](/documentation/SwiftUI/View/gridCellColumns(_:))

Tells a view that acts as a cell in a grid to span the specified
number of columns.

[`gridCellAnchor(_:)`](/documentation/SwiftUI/View/gridCellAnchor(_:))

Specifies a custom alignment anchor for a view that acts as a grid cell.

[`gridCellUnsizedAxes(_:)`](/documentation/SwiftUI/View/gridCellUnsizedAxes(_:))

Asks grid layouts not to offer the view extra size in the specified
axes.

[`gridColumnAlignment(_:)`](/documentation/SwiftUI/View/gridColumnAlignment(_:))

Overrides the default horizontal alignment of the grid column that
the view appears in.

### Safe area and margins

[`ignoresSafeArea(_:edges:)`](/documentation/SwiftUI/View/ignoresSafeArea(_:edges:))

Expands the safe area of a view.

[`ignoresSafeArea(_:edges:alignment:)`](/documentation/SwiftUI/View/ignoresSafeArea(_:edges:alignment:))

Expands the safe area of a view aligning content within the new
bounds using the provided alignment.

[`safeAreaInset(edge:alignment:spacing:content:)`](/documentation/SwiftUI/View/safeAreaInset(edge:alignment:spacing:content:))

Shows the specified content beside the modified view.

[`safeAreaBar(edge:alignment:spacing:content:)`](/documentation/SwiftUI/View/safeAreaBar(edge:alignment:spacing:content:))

Shows the specified content as a custom bar beside the modified view.

[`safeAreaPadding(_:)`](/documentation/SwiftUI/View/safeAreaPadding(_:))

Adds the provided insets into the safe area of this view.

[`safeAreaPadding(_:_:)`](/documentation/SwiftUI/View/safeAreaPadding(_:_:))

Adds the provided insets into the safe area of this view.

[`contentMargins(_:for:)`](/documentation/SwiftUI/View/contentMargins(_:for:))

Configures the content margin for a provided placement.

[`contentMargins(_:_:for:)`](/documentation/SwiftUI/View/contentMargins(_:_:for:))

Configures the content margin for a provided placement.

### Layer order

[`zIndex(_:)`](/documentation/SwiftUI/View/zIndex(_:))

Controls the display order of overlapping views.

### Layout direction

[`layoutDirectionBehavior(_:)`](/documentation/SwiftUI/View/layoutDirectionBehavior(_:))

Sets the behavior of this view for different layout directions.

### Custom layout characteristics

[`layoutValue(key:value:)`](/documentation/SwiftUI/View/layoutValue(key:value:))

Associates a value with a custom layout property.

[`containerValue(_:_:)`](/documentation/SwiftUI/View/containerValue(_:_:))

Sets a particular container value of a view.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)