<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/responding-to-geometry-changes-in-swiftui-hosixtvxh" -->

---
title: Responding to geometry changes in SwiftUI | daily.dev
description: Adaptive iOS interfaces now need to respond to a wider range of window sizes since apps can be freely resized on iPad, and iPhone-only apps built with the iOS...
canonical: https://daily.dev/posts/responding-to-geometry-changes-in-swiftui-hosixtvxh
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Responding to geometry changes in SwiftUI | daily.dev
og:description: Adaptive iOS interfaces now need to respond to a wider range of window sizes since apps can be freely resized on iPad, and iPhone-only apps built with the iOS...
og:url: https://daily.dev/posts/responding-to-geometry-changes-in-swiftui-hosixtvxh
og:image: https://api.daily.dev/og/posts/HosIxtvXH.png
og:image:alt: Responding to geometry changes in SwiftUI
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Responding to geometry changes in SwiftUI

**[Nil Coalescing](https://daily.dev/sources/nilcoalescing)** · 4 min read · 1 upvotes · 0 comments

## Summary

Adaptive iOS interfaces now need to respond to a wider range of window sizes since apps can be freely resized on iPad, and iPhone-only apps built with the iOS 27 SDK can be resized on iPad or via iPhone Mirroring on Mac. The onGeometryChange(for:of:action:) modifier lets a view derive a custom value, such as whether to use a vertical or horizontal card layout, from its resolved geometry (size, safe-area insets, or frame). A worked example shows deriving a Boolean layout flag from a ScrollView's size and width threshold, with the action closure only firing when the derived value changes, avoiding redundant state updates during resizes. Guidance is given on keeping derived state independent from the geometry that produced it to avoid feedback loops between layout and state.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://nilcoalescing.com/blog/RespondingToGeometryChangesInSwiftUI>

## Questions this post answers

### How do I use onGeometryChange in SwiftUI to switch a layout between vertical and horizontal arrangements based on available size?

Apply onGeometryChange(for:of:action:) to a container view like ScrollView, passing Bool.self as the value type. The transform closure reads the GeometryProxy's size and returns true when height exceeds width and width is below a threshold; the action closure only fires when this Boolean changes, assigning the result to a state property that drives the arrangement.

_daily.dev surfaces practical SwiftUI patterns for developers building resizable, adaptive interfaces._

### Why does my SwiftUI onGeometryChange action get called repeatedly during a window resize?

Repeated calls usually happen when the state updated by the action closure influences the geometry being measured, creating a feedback loop between layout and state. To avoid this, keep the derived state independent of the geometry it comes from, and return only the minimal value needed (such as a Boolean) so the action only triggers when that specific result actually changes.

_Developers debugging SwiftUI layout feedback loops can find focused fixes like this on daily.dev._

## Similar posts on daily.dev

- [Building adaptive SwiftUI layouts with containerRelativeFrame\(\)](https://daily.dev/posts/building-adaptive-swiftui-layouts-with-containerrelativeframe--ouf2erf86) · Nil Coalescing · 1 upvotes · 0 comments

---

Tags: [#ios](https://daily.dev/tags/ios), [#ui-design](https://daily.dev/tags/ui-design), [#swift](https://daily.dev/tags/swift), [#swiftui](https://daily.dev/tags/swiftui)

[View this post on daily.dev](https://daily.dev/posts/responding-to-geometry-changes-in-swiftui-hosixtvxh)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Responding to geometry changes in SwiftUI","url":"https://daily.dev/posts/responding-to-geometry-changes-in-swiftui-hosixtvxh","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/responding-to-geometry-changes-in-swiftui-hosixtvxh"},"datePublished":"2026-08-17T09:45:40.789Z","dateModified":"2026-09-14T09:20:23.534Z","description":"Adaptive iOS interfaces now need to respond to a wider range of window sizes since apps can be freely resized on iPad, and iPhone-only apps built with the iOS...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/78e1609053d331db0db9ca0bf00bbbb5?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/78e1609053d331db0db9ca0bf00bbbb5?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Nil Coalescing","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Nil Coalescing","logo":"https://media.daily.dev/image/upload/s--rcEu6sag--/f_auto,q_auto/v1785654899/logos/nilcoalescing?_a=BAMAMicg0","url":"https://daily.dev/sources/nilcoalescing"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/responding-to-geometry-changes-in-swiftui-hosixtvxh","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"ios,ui-design,swift,swiftui","timeRequired":"PT4M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Nil Coalescing","item":"https://daily.dev/sources/nilcoalescing"},{"@type":"ListItem","position":3,"name":"Responding to geometry changes in SwiftUI"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/responding-to-geometry-changes-in-swiftui-hosixtvxh#faq","mainEntity":[{"@type":"Question","name":"How do I use onGeometryChange in SwiftUI to switch a layout between vertical and horizontal arrangements based on available size?","acceptedAnswer":{"@type":"Answer","text":"Apply onGeometryChange(for:of:action:) to a container view like ScrollView, passing Bool.self as the value type. The transform closure reads the GeometryProxy's size and returns true when height exceeds width and width is below a threshold; the action closure only fires when this Boolean changes, assigning the result to a state property that drives the arrangement. daily.dev surfaces practical SwiftUI patterns for developers building resizable, adaptive interfaces."}},{"@type":"Question","name":"Why does my SwiftUI onGeometryChange action get called repeatedly during a window resize?","acceptedAnswer":{"@type":"Answer","text":"Repeated calls usually happen when the state updated by the action closure influences the geometry being measured, creating a feedback loop between layout and state. To avoid this, keep the derived state independent of the geometry it comes from, and return only the minimal value needed (such as a Boolean) so the action only triggers when that specific result actually changes. Developers debugging SwiftUI layout feedback loops can find focused fixes like this on daily.dev."}}]}
```

