How it works
ScrollIndicatorVisibility expresses whether a scroll view should draw its scroll indicators, and how insistently. Rather than passing a raw boolean, you describe intent — show them, hide them, let the system decide, or never reserve space for them at all — and SwiftUI resolves that intent against the platform and the user's scrolling. Reach for it whenever the default indicator behavior fights your layout: when a content area always needs visible affordances, or when chrome-free presentations should keep indicators out of the way.
Pass a visibility value to scrollIndicators(_:)
ScrollIndicatorVisibility is the argument type of the scrollIndicators(_:) modifier. You attach the modifier to a scrollable container and hand it one of the type's values to govern that view's indicators, as in
.scrollIndicators(.visible)applied to theScrollView.Choose .visible to keep indicators on screen
The
.visiblevalue asks SwiftUI to show the scroll indicators whenever the content can scroll, instead of letting them auto-hide. It's the value used in the example to guarantee a persistent affordance alongside the scrolling rows ofText.Reach for .hidden or .never to suppress them
Beyond
.visible, ScrollIndicatorVisibility offers.hiddento keep the indicators off screen while still allowing the system to reveal them in some contexts, and.neverto fully prevent them. Swapping.scrollIndicators(.visible)for either changes only the indicator chrome, not the scrolling itself.Fall back to .automatic for platform defaults
The
.automaticvalue defers to SwiftUI's standard, platform-appropriate behavior — typically indicators that appear during scrolling and fade away. Use it when you want to clear an inherited override and return aScrollViewto its default look.Scope visibility to specific axes
Because the value is paired with scrollIndicators(_:), which also takes an axes parameter, you can confine a ScrollIndicatorVisibility setting to the horizontal or vertical indicators. The example's modifier defaults to both axes, but the same value could target just one direction of the
ScrollView.
.scrollIndicators(.visible) to .scrollIndicators(.hidden) and scroll the rows — the indicator disappears while the content still scrolls.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 ScrollIndicatorVisibilityDemo: View {
var body: some View {
ScrollView {
ForEach(1..<21) { i in
Text("Row \(i)")
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.vertical, 8)
}
}
.scrollIndicators(.visible)
.padding()
}
}