<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/CoordinateSpaceProtocol",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI23CoordinateSpaceProtocolP"
  },
  "title" : "CoordinateSpaceProtocol"
}
-->

# CoordinateSpaceProtocol

A frame of reference within the layout system.

```
protocol CoordinateSpaceProtocol
```

## Overview

All geometric properties of a view, including size, position, and
transform, are defined within the local coordinate space of the view’s
parent. These values can be converted into other coordinate spaces
by passing types conforming to this protocol into functions such as
`GeometryProxy.frame(in:)`.

For example, a named coordinate space allows you to convert the frame
of a view into the local coordinate space of an ancestor view by defining
a named coordinate space using the `coordinateSpace(_:)` modifier, then
passing that same named coordinate space into the `frame(in:)` function.

```
VStack {
    GeometryReader { geometryProxy in
        let distanceFromTop = geometryProxy.frame(in: "container").origin.y
        Text("This view is \(distanceFromTop) points from the top of the VStack")
    }
    .padding()
}
.coordinateSpace(.named("container"))
```

You don’t typically create types conforming to this protocol yourself.
Instead, use the system-provided `.global`, `.local`, and `.named(_:)`
implementations.

## Topics

### Getting built-in coordinate spaces

[`immersiveSpace`](/documentation/SwiftUI/CoordinateSpaceProtocol/immersiveSpace)

The named coordinate space that represents the currently opened
[`ImmersiveSpace`](/documentation/SwiftUI/ImmersiveSpace) scene.
If no immersive space is currently opened, this CoordinateSpace provides
the same behavior as the `.global` coordinate space.

[`global`](/documentation/SwiftUI/CoordinateSpaceProtocol/global)

The global coordinate space at the root of the view hierarchy.

[`local`](/documentation/SwiftUI/CoordinateSpaceProtocol/local)

The local coordinate space of the current view.

[`named(_:)`](/documentation/SwiftUI/CoordinateSpaceProtocol/named(_:))

Creates a named coordinate space using the given value.

[`scrollView`](/documentation/SwiftUI/CoordinateSpaceProtocol/scrollView)

The named coordinate space that is added by the system for the innermost
containing scroll view.

[`scrollView(axis:)`](/documentation/SwiftUI/CoordinateSpaceProtocol/scrollView(axis:))

The named coordinate space that is added by the system for the innermost
containing scroll view that allows scrolling along the provided axis.

### Getting the resolved coordinate space

[`coordinateSpace`](/documentation/SwiftUI/CoordinateSpaceProtocol/coordinateSpace)

The resolved coordinate space.

### Supporting types

[`GlobalCoordinateSpace`](/documentation/SwiftUI/GlobalCoordinateSpace)

The global coordinate space at the root of the view hierarchy.

[`LocalCoordinateSpace`](/documentation/SwiftUI/LocalCoordinateSpace)

The local coordinate space of the current view.

[`NamedCoordinateSpace`](/documentation/SwiftUI/NamedCoordinateSpace)

A named coordinate space.



---

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)