TechnologiesSwiftUIScrolling

ScrollIndicatorVisibility struct

iOSmacOStvOSwatchOSvisionOSiOS 16.0+✓ renders

The visibility of scroll indicators of a UI element.

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.

  1. 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 the ScrollView.

  2. Choose .visible to keep indicators on screen

    The .visible value 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 of Text.

  3. Reach for .hidden or .never to suppress them

    Beyond .visible, ScrollIndicatorVisibility offers .hidden to keep the indicators off screen while still allowing the system to reveal them in some contexts, and .never to fully prevent them. Swapping .scrollIndicators(.visible) for either changes only the indicator chrome, not the scrolling itself.

  4. Fall back to .automatic for platform defaults

    The .automatic value 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 a ScrollView to its default look.

  5. 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.

Try it — Change .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.

ScrollIndicatorVisibility.swift
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()
    }
}
Live preview
Row 1 Row 2 Row 3 Row 4 Row 5 Row 6 Row 7 Row 8 Row 9 Row 10 Row 11 Row 12 Row 13 Row 14 Row 15 Row 16 Row 17 Row 18 Row 19 Row 20
Row 1 Row 2 Row 3 Row 4 Row 5 Row 6 Row 7 Row 8 Row 9 Row 10 Row 11 Row 12 Row 13 Row 14 Row 15 Row 16 Row 17 Row 18 Row 19 Row 20
swift → lexer → parser → sema → uiir → canvas Open in Studio ↗
What's new in SwiftUI 27 →