---
title: "depthAlignment(_:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/layout/depthalignment(_:)"
---

# depthAlignment(_:)

Sets the depth alignment for this layout.

## Declaration

```swift
func depthAlignment(_ alignment: DepthAlignment) -> some Layout

```

## Parameters

- `alignment`: A doc://com.apple.SwiftUI/documentation/SwiftUI/DepthAlignment value to use for aligning layout’s subviews

## Discussion

Discussion Use depthAlignment(_:) to specify a depth guide for aligning subviews of this layout. In the example below, the button to play the robot animation is aligned to the .front of the HStack.    let depthStack = HStackLayout().depthAlignment(.front)    depthStack {        RobotModel()        Button("Play animation") {            playRobotAnimation()        }        .glassBackgroundEffect()    }
