ScrollViewReader { proxy in ScrollView(.horizontal, showsIndicators: false) { HStack { // or LazyHStack ForEach(0..<items.count) { index in Text(items[index].title) .id(index) .onTapGesture { print("tapped \(index)") } } } .onAppear { DispatchQueue.main.async { proxy.scrollTo(selectedIndex, anchor: .center) } } } }