In order to auto-scroll the messages to the last send message, we'll utilize the ScrollViewReader component.
private var messagesView: some View { VStack { ScrollView { ScrollViewReader { scrollViewProxy in VStack { ForEach(vm.chatMessages) { message in MessageView(message: message) } HStack{ Spacer() } .id(Self.emptyScrollToString) } .onReceive(vm.$count) { _ in withAnimation(.easeOut(duration: 0.5)) { scrollViewProxy.scrollTo(Self.emptyScrollToString, anchor: .bottom) } } } } .background(Color(.init(white: 0.95, alpha: 1))) .safeAreaInset(edge: .bottom) { chatBottomBar .background(Color(.systemBackground).ignoresSafeArea()) } }}