How it works
ToolbarMinimizationSafeAreaAdjustment controls how a scroll view's safe area responds when a minimizable toolbar collapses out of the way. When a toolbar minimizes as the user scrolls, the space it once occupied can either be reclaimed by your content or held in reserve, and this type lets you choose between those policies rather than accepting the default. Reach for it through the toolbarMinimizationSafeAreaAdjustment(_:) modifier whenever a toolbar's appear-and-disappear behavior causes your content to shift or clip in ways you want to tune.
Choose an adjustment policy with the value
ToolbarMinimizationSafeAreaAdjustment is a value type whose cases describe how aggressively SwiftUI reclaims the toolbar's safe-area inset as it minimizes. In the example the
.automaticcase lets the framework pick the standard behavior for the platform and toolbar placement, which is the right starting point before you opt into anything more specific.Apply it with toolbarMinimizationSafeAreaAdjustment(_:)
You hand the value to the view modifier of the same name, which threads the policy down to the scrollable content that shares the toolbar's safe area. Here
.toolbarMinimizationSafeAreaAdjustment(.automatic)is attached alongside.navigationTitle("Inbox")on theScrollView, so the adjustment governs how the inbox list reflows when the bar collapses.Pair it with a minimizable toolbar
The adjustment only has something to do when a toolbar can actually minimize, so it lives next to a
.toolbardeclaration. In the example theToolbarItem(placement: .bottomBar)holding theButton("Compose", systemImage: "square.and.pencil")is the bar whose collapse the safe-area policy responds to.Let it ride on the scrolling content
Because the policy is about safe-area insets, it takes effect as the user scrolls the surrounding
ScrollView. TheForEach(1..<20)rows are what move through that changing inset, and the adjustment decides whether they slide up into the toolbar's vacated space or keep their original margin as the bar minimizes.
.toolbarMinimizationSafeAreaAdjustment(.automatic) for a different case and scroll the inbox to watch whether the ForEach rows reclaim the bottom bar's space or leave it reserved as the toolbar minimizes.Example & preview
Press Run live & edit to compile it in your browser — then edit the Swift on the left and the preview re-renders live.
struct ToolbarMinimizationSafeAreaAdjustmentDemo: View {
var body: some View {
NavigationStack {
ScrollView {
VStack(alignment: .leading, spacing: 12) {
ForEach(1..<20) { i in
Text("Row \(i)")
.frame(maxWidth: .infinity, alignment: .leading)
.padding()
.background(.quaternary)
.clipShape(RoundedRectangle(cornerRadius: 8))
}
}
.padding()
}
.navigationTitle("Inbox")
.toolbarMinimizationSafeAreaAdjustment(.automatic)
.toolbar {
ToolbarItem(placement: .bottomBar) {
Button("Compose", systemImage: "square.and.pencil") {}
}
}
}
}
}