<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/DepthAlignmentID/defaultValue(in:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI16DepthAlignmentIDP12defaultValue2in14CoreFoundation7CGFloatVAA16ViewDimensions3DV_tFZ"
  },
  "title" : "defaultValue(in:)"
}
-->

# defaultValue(in:)

Calculates a default value for the corresponding guide in the specified
context.

```
static func defaultValue(in context: ViewDimensions3D) -> CGFloat
```

## Parameters

`context`

The context of the view that you apply
the alignment guide to. The context gives you the view’s dimensions,
as well as the values of other alignment guides that apply to the
view, including both built-in and custom guides. You can use any of
these values, if helpful, to calculate the value for your custom
guide.

## Return Value

The offset of the guide from the origin in the
view’s coordinate space.

## Discussion

Implement this method when you create a type that conforms to the
[`DepthAlignmentID`](/documentation/SwiftUI/DepthAlignmentID) protocol. Use the method to calculate the default
offset of the corresponding alignment guide. SwiftUI interprets the
value that you return as an offset in the coordinate space of the
view that’s being laid out. For example, you can use the context to
return a value that’s one-third of the height of the view:

```
private struct FirstThirdAlignment: DepthAlignmentID {
    static func defaultValue(in context: ViewDimensions3D) -> CGFloat {
        context.depth / 3
    }
}
```

You can override the default value that this method returns for a
particular guide by adding the
[`alignmentGuide(_:computeValue:)`](/documentation/SwiftUI/View/alignmentGuide(_:computeValue:)) view modifier to a
particular 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)