CarouselView

1.1.2

This library simplifies the implementation of carousel-style interfaces in SwiftUI applications while maintaining smooth, infinite scrolling functionality.
AnbalaganD/CarouselView

What's New

1.1.2

2025-12-27T13:49:34Z

CarouselView β€” Release Notes

Summary

Added user interaction tracking and improved auto-scroll behavior.

Highlights

  • New onCarouselInteraction modifier to observe when a user is interacting (dragging/tapping).
  • AutoscrollModifier now pauses during user interaction and resumes afterwards.
  • CarouselView exposes interaction state so parent views and modifiers can react.
  • Documentation and README examples updated with usage and guidance.

Notes

Use .onCarouselInteraction { isInteracting in ... } to pause timers, log analytics, or adjust UI while users engage with the carousel.

Full Changelog: 1.1.1...1.1.2

This library simplifies the implementation of carousel-style interfaces in SwiftUI applications while maintaining smooth, infinite scrolling functionality.

CarouselView

Features

♾️ Infinite scrolling support

🎯 Selected item tracking

πŸ“ Configurable item spacing

πŸ“ Current index monitoring

πŸ”„ Auto-scroll with customizable interval

⏸️ Auto-pause on user interaction

⚑️ Native SwiftUI implementation

Swift Package manager (SPM)

CarouselView is available through SPM. Use below URL to add as a dependency

dependencies: [
    .package(url: "https://github.com/AnbalaganD/CarouselView", .upToNextMajor(from: "1.1.2"))
]

Usage

Basic Usage

import CarouselView

struct ContentView: View {
    private let items: [String] = ["One", "Two", "Three", "Four", "Five"]
    @State private var selectedIndex: Int = 2
    
    var body: some View {
        CarouselView(
            items,
            spacing: 10.0,
            selectedIndex: $selectedIndex
        ) { item in
            Text(item)
                .frame(maxWidth: .infinity)
                .frame(height: 200)
                .background(Color.gray)
                .clipShape(RoundedRectangle(cornerSize: .init(width: 5, height: 5)))
        }
    }
}

Auto-scroll

struct ContentView: View {
    private let items: [String] = ["One", "Two", "Three", "Four", "Five"]
    @State private var selectedIndex: Int = 0
    @State private var autoScrollEnabled: Bool = true
    
    var body: some View {
        CarouselView(
            items,
            spacing: 10.0,
            selectedIndex: $selectedIndex
        ) { item in
            Text(item)
                .frame(maxWidth: .infinity)
                .frame(height: 200)
                .background(Color.blue)
                .clipShape(RoundedRectangle(cornerSize: .init(width: 5, height: 5)))
        }
        .autoscroll($autoScrollEnabled, interval: 3.0)
    }
}

Auto-scroll automatically pauses when the user interacts with the carousel and resumes when interaction ends.

Observing User Interaction

struct ContentView: View {
    private let items: [String] = ["One", "Two", "Three", "Four", "Five"]
    @State private var selectedIndex: Int = 0
    
    var body: some View {
        CarouselView(
            items,
            spacing: 10.0,
            selectedIndex: $selectedIndex
        ) { item in
            Text(item)
                .frame(maxWidth: .infinity)
                .frame(height: 200)
                .background(Color.blue)
                .clipShape(RoundedRectangle(cornerSize: .init(width: 5, height: 5)))
        }
        .onCarouselInteraction { isInteracting in
            print("User is interacting: \(isInteracting)")
        }
    }
}

Author

Anbalagan D

License

CarouselView is available under the MIT license. See the LICENSE file for more info.

Description

  • Swift Tools 5.9.0
View More Packages from this Author

Dependencies

  • None
Last updated: Sun Jan 18 2026 18:17:40 GMT-1000 (Hawaii-Aleutian Standard Time)