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

# depthAlignment(_:content:)

Creates a layout view with the specified depth alignment.

## Declaration

```swift
nonisolated func depthAlignment<Content>(_ alignment: DepthAlignment, @ContentBuilder content: () -> Content) -> some View where Content : View

```

## Parameters

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

## Discussion

Discussion Use depthAlignment(_:content:) 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.    HStackLayout().depthAlignment(.front) {        RobotModel()        Button("Play animation") {            playRobotAnimation()        }        .glassBackgroundEffect()    }
