---
title: "onHingeChange(isEnabled:_:)"
framework: SwiftUI
role: symbol
role_heading: Instance Method
platforms: [iOS 27.1+, iPadOS 27.1+]
path: "swiftui/view/onhingechange(isenabled:_:)"
---

# onHingeChange(isEnabled:_:)

Adds an action to perform when the hinge context of the view hierarchy changes.

## Declaration

```swift
nonisolated func onHingeChange(isEnabled: Bool = true, _ action: @escaping (DeviceHingeContext, DeviceHingeContext) -> Void) -> some View

```

## Discussion

Discussion Use this modifier to be informed of changes to the hinge context of the device. @State private var hinge: DeviceHinge? = nil

var body: some View {     VStack {         if let hinge {             AngleDisplayView(angle: hinge.angle)             StatusDisplayView(status: hinge.status)         } else {             ContentUnavailableView(                 "Hinge Unavailable",                 systemImage: "rectangle.split.2x1")         }     }     .onHingeChange { _, newContext in         hinge = newContext.hinge     } } In the example above, the current angle and status of the hinge will be displayed in the app as you interact with the hinge.

## See Also

### Responding to hinge angle changes

- [DeviceHingeContext](swiftui/devicehingecontext.md)
- [DeviceHinge](swiftui/devicehinge.md)
