<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/frame(depth:alignment:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE5frame5depth9alignmentQr14CoreFoundation7CGFloatVSg_AA14DepthAlignmentVtF"
  },
  "title" : "frame(depth:alignment:)"
}
-->

# frame(depth:alignment:)

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

```
@export(implementation) nonisolated func frame(depth: CGFloat?, alignment: DepthAlignment = .center) -> some View
```

## Parameters

`depth`

A fixed depth for the resulting view. If `depth` is `nil`,
the resulting view assumes this view’s sizing behavior.

`alignment`

The alignment of this view inside the resulting view.
`alignment` applies if this view is smaller than the size given by
the resulting frame.

## Return Value

A view with a fixed dimension of `depth` if non-`nil`.

## Discussion

Use this method to specify a fixed size for a view’s depth. If you don’t
specify a dimension, the resulting view assumes this view’s sizing
behavior in depth.

---

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)