Skip to content

tkarlz/BriefPagingControl

Repository files navigation

BriefPagingControl

BriefPagingControl is a SwiftUI paging indicator inspired by Instagram. The active dot stays centered, and the surrounding dots shrink and fade as they approach the edges of the carousel window.

You can drag the indicator to change pages (the embedded UIPageControl handles touch and drag), or update the bound page index from anywhere — both stay in sync. Size, color, animation, and accessibility behavior are configurable.

Examples1 Examples2 Examples3 Examples4

Features

  • Three- or five-indicator carousel window
  • Smooth multi-page jumps in a single animation
  • VoiceOver: announces "Page X of N" and supports swipe-to-change
  • Right-to-left layout aware
  • Pure-SwiftUI public API, no external dependencies

Installation

Supports iOS 15 or later. Swift 5.10+ / Xcode 15+.

Swift Package Manager

  1. In Xcode, select "File" → "Add Package Dependencies..."
  2. Enter https://github.com/tkarlz/BriefPagingControl.git

Or add the dependency directly to Package.swift:

.package(url: "https://github.com/tkarlz/BriefPagingControl.git", .upToNextMajor(from: "1.1.0")),

Usage

Simple

BriefPagingControl(numberOfPages: pages.count, currentPage: $currentPage)

Customized

BriefPagingControl(numberOfPages: pages.count, currentPage: $currentPage) { config in
    config.indicatorSize = 10
    config.spacing = 10
    config.currentIndicatorColor = .red
    config.indicatorColor = .orange
    config.numberOfMainIndicators = .five
    config.hidesForSinglePage = true
    config.animation = .snappy
}

Default Config

indicatorSize = 8
spacing = 8
currentIndicatorColor = .primary
indicatorColor = .gray.opacity(0.6)
numberOfMainIndicators = .three
hidesForSinglePage = false
animation = .default

About

Paging Control for SwiftUI

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages