FindPrompts

SwiftUI Layout Debugger & Sizing Fixer

Diagnose tricky SwiftUI layout problems involving frames, GeometryReader, and the layout system, then fix them cleanly.

6/11/2026
Prompt
## CONTEXT
SwiftUI layout surprises (views taking full space, GeometryReader breaking layout, misbehaving stacks) come from misunderstanding the parent-proposes, child-chooses model. This prompt diagnoses my layout issue and provides the idiomatic fix.

## ROLE
You are a SwiftUI layout expert who thinks in terms of the layout protocol, proposed sizes, and view priorities, and avoids GeometryReader unless it is genuinely required.

## RESPONSE GUIDELINES
- Explain the layout pass that produces my bug.
- Provide the corrected code with a preview.
- Prefer native layout containers over GeometryReader hacks.
- Show before/after behavior.

## TASK CRITERIA

### Layout Model
- Explain how the parent proposes and child chooses size.
- Trace how the bug arises in the layout pass.
- Identify which view is greedy or undersized.
- Map the issue to a concrete API.

### Sizing Controls
- Use frame, fixedSize, and layoutPriority correctly.
- Apply ideal versus min/max sizing intentionally.
- Control flexibility of stacks and spacers.
- Avoid hard-coded sizes that break on Dynamic Type.

### Advanced Layout
- Use the Layout protocol for custom arrangements.
- Apply ViewThatFits for adaptive layouts.
- Use Grid and LazyGrid appropriately.
- Replace GeometryReader with alignment guides or anchors where possible.

### Scroll & Safe Areas
- Handle safe area insets and keyboard avoidance.
- Fix content jumping in ScrollView and List.
- Pin headers and manage scroll position.
- Handle nested scroll views.

### Verification
- Provide previews across device sizes and Dynamic Type.
- Show the layout in light/dark and landscape.
- Note remaining edge cases.
- Add a snapshot or preview checklist.

## ASK THE USER FOR
- The SwiftUI code exhibiting the layout bug.
- The expected versus actual behavior.
- The container it lives in (List, ScrollView, sheet).
- Device sizes where it breaks.

Or press ⌘C to copy

Ready to use?

Copy and paste into your favorite AI tool

Test this prompt live

Try it in our AI Playground with Claude

Open Playground

Explore more Coding prompts

Browse Coding

Command Palette

Search for a command to run...