
PagerKit
Expert guidance on PagerKit, a SwiftUI library for advanced, customizable page-based navigation. Use when developers mention: (1) PagerKit, PKPagesView, PKPage, (2) custom page controls, indicators, or paging behavior, (3) cross-platform SwiftUI paging, (4) dynamic page generation, (5) integrating page views into custom layouts, (6) specific PagerKit modifiers or enums, (7) page view controller options, (8) event handling for page changes.
'Expert guidance on PagerKit, a SwiftUI library for advanced, customizable page-based navigation. Use when developers mention: (1) PagerKit, PKPagesView, PKPage, (2) custom page controls, indicators, or paging behavior, (3) cross-platform SwiftUI paging, (4) dynamic page generation, (5) integrating page views into custom layouts, (6) specific PagerKit modifiers or enums, (7) page view controller options, (8) event handling for page changes.'
PagerKit Skill
Overview
This skill provides expert guidance on PagerKit, a powerful SwiftUI library for creating highly customizable and cross-platform page-based navigation. It covers everything from basic usage and dynamic page generation to advanced customization of page indicators, event handling, and best practices. Use this skill to help developers effectively implement flexible and visually rich paging experiences in their SwiftUI applications across all Apple platforms.
Agent Behavior (Follow These Rules)
- Clarify Paging Requirements: Always ascertain the user's specific needs regarding page content, indicator style, navigation flow, and platform targets before offering solutions.
- Prioritize idiomatic SwiftUI: Favor PagerKit's
PKPageBuilderandForEachfor declarative page construction, aligning with SwiftUI's design principles. - Platform-Specific Advice: When discussing indicator images, progress, or
UIPageViewControlleroptions, always specify platform availability and correct type (UIImagevs.Image,UIPageControlProgress). - Emphasize Modifiers: Direct users to the relevant
PKPagesVieworPKPagemodifiers for customization, using full modifier signatures (e.g.,.pkPageNavigationOrientation(_:)). - Contextual Code Examples: Provide concise code snippets that illustrate the recommended usage within a
PKPagesVieworPKPagecontext. - Highlight Cross-Platform: When possible, remind users of PagerKit's cross-platform consistency and how to handle platform-specific differences using
#if os(...)directives.
Project Settings
PagerKit's behavior is influenced by the project's deployment targets and Swift version.
- Deployment Targets: PagerKit supports iOS 14.0+, iPadOS 14.0+, macOS 14.0+, tvOS 14.0+, visionOS 1.0+, and watchOS 10.0+. Some features (e.g.,
UIPageControlProgress) are only available on specific platforms and OS versions. - Swift Version: Requires Swift 5.9+.
If these are unknown, ask the developer to confirm them, especially when discussing platform-specific features.
Quick Decision Tree
When a developer needs PagerKit guidance, follow this decision tree:
-
Setting up a new pager?
- For basic installation and concepts →
references/PagerKit.md - To define the overall pager structure →
references/PKPagesView.md - To create individual page content →
references/PKPage.md
- For basic installation and concepts →
-
Generating pages dynamically from data?
- Using a collection of items →
references/ForEach.md
- Using a collection of items →
-
Controlling page flow or structure?
- Adding conditional pages (if/else) →
references/PKPageBuilder.md - Setting horizontal or vertical navigation →
references/PKPagesView.md(.pkPageNavigationOrientation)
- Adding conditional pages (if/else) →
-
Customizing the page indicator (dots)?
- Changing color (active/inactive) →
references/PKPagesView.md(.pkPageControlIndicatorTintColor,.pkPageControlIndicatorCurrentIndicatorTintColor) - Changing background style (minimal, prominent, automatic) →
references/PKPageControlBackgroundStyle.md - Adjusting position or spacing →
references/PKPagesView.md(.pkPageControlIndicatorAlignment,.pkPageControlPadding) - Setting layout direction (e.g., vertical alignment) →
references/PKPageControlDirection.md - Using custom images (global or per-page) →
references/PKPagesView.md,references/PKPage.md - Hiding the indicator (always or for single page) →
references/PKPagesView.md
- Changing color (active/inactive) →
-
Handling page change events or state?
- Binding to the current page index →
references/PKPagesView.md(.pkCurrentPageIndex) - Reacting to manual page changes →
references/PKPagesView.md(.pkOnManualPageChange) - Reacting to automatic page changes →
references/PKPagesView.md(.pkOnAutoPageChange) - Identifying page transition direction →
references/PKPageDirection.md - Actions on transition start/end →
references/PKPagesView.md
- Binding to the current page index →
-
Customizing individual page behavior?
- Setting automatic transition duration →
references/PKPage.md(.pkPageDuration) - Adding a custom footer to a page →
references/PKPage.md(.pkPageFooter)
- Setting automatic transition duration →
Triage-First Playbook
- "My pages are not showing or look incorrect."
- Verify
PKPagesViewcontains validPKPageinstances. Refer toreferences/PKPagesView.md,references/PKPage.md. - If using dynamic content, check
ForEachimplementation. Refer toreferences/ForEach.md.
- Verify
- "The page indicator is not positioned or styled correctly."
- Examine
.pkPageControlIndicatorAlignment,.pkPageControlIndicatorBackgroundStyle,.pkPageControlIndicatorDirectionmodifiers onPKPagesView. Refer toreferences/PKPagesView.md,references/PKPageControlBackgroundStyle.md,references/PKPageControlDirection.md.
- Examine
- "I want to change the color of the active dot, but it's not working."
- Ensure
.pkPageControlIndicatorCurrentIndicatorTintColor(_:)is used onPKPagesView. Refer toreferences/PKPagesView.md.
- Ensure
- "Pages are not transitioning automatically."
- Check if
.pkPageDuration(_:)is applied to the individualPKPages with a non-nil duration. Refer toreferences/PKPage.md.
- Check if
- "My conditional logic (
ifstatements) insidePKPagesViewis giving compiler errors."- Review
PKPageBuilderconcepts, ensuring all branches return validPKPagecomponents. Refer toreferences/PKPageBuilder.md.
- Review
- "How can I tell if the user swiped forward or backward?"
- Use the
PKPageDirectionparameter in.pkOnManualPageChange. Refer toreferences/PKPagesView.md,references/PKPageDirection.md.
- Use the
Core Patterns Reference
Basic Pager Setup
PKPagesView {
PKPage { Text("Page A").font(.title) }
PKPage { Text("Page B").font(.title) }
PKPage { Text("Page C").font(.title) }
}
.pkCurrentPageIndex(index: $currentPage) // Bind to @State
.pkPageNavigationOrientation(.horizontal)
Dynamic Pages with ForEach
struct Item: Identifiable {
let id = UUID()
let title: String
}
// ... inside a View
let items = [Item(title: "Item 1"), Item(title: "Item 2")]
PKPagesView {
ForEach(items) { item in
PKPage { Text(item.title) }
.pkPageFooter { Text("Footer for \(item.title)") }
}
}
Custom Page Indicator Styling
.pkPageControlIndicatorAlignment(spacing: 10, alignment: .bottomTrailing)
.pkPageControlIndicatorBackgroundStyle(.prominent)
.pkPageControlIndicatorDirection(.topToBottom) // Vertical dots
.pkPageControlIndicatorTintColor(.gray)
.pkPageControlIndicatorCurrentIndicatorTintColor(.blue)
// Custom images
#if os(iOS)
.pkPageControlIndicatorPreferredCurrentPageIndicatorImage(image: UIImage(systemName: "star.fill"))
#else
.pkPageControlIndicatorPreferredCurrentPageIndicatorImage(image: Image(systemName: "star.fill"))
#endif
Handling Page Change Events
.pkOnManualPageChange { currentIndex, direction in
print("User navigated to page \(currentIndex) by going \(direction).")
}
.pkOnAutoPageChange { previousIndex, currentIndex in
print("Auto change from \(previousIndex) to \(currentIndex).")
}
.pkOnTransitionEnd { previous, current in
print("Transition ended. Was on \(previous), now on \(current).")
}
Integration Quick Guide
PagerKit is integrated via Swift Package Manager.
- Add Package Dependency: In Xcode, go to File > Add Package Dependency and enter
https://github.com/SzpakKamil/PagerKit.git. - Import:
import PagerKitin your Swift files. - Deployment Targets: Ensure your project targets iOS 14.0+, iPadOS 14.0+, macOS 14.0+, tvOS 14.0+, visionOS 1.0+, or watchOS 10.0+ (Swift 5.9+).
For detailed setup, see references/PagerKit.md.
Reference Files
Load these files as needed for specific topics:
PagerKit.md- General overview, setup, and core benefits.PKPagesView.md- Detailed information on the main pager container and its global modifiers.PKPage.md- Information on individual page creation and page-specific modifiers.ForEach.md- How to generate pages from collections of data.PKPageBuilder.md- Understanding the declarative content building forPKPagesView.PKPageControlBackgroundStyle.md- Options for the background style of the page indicator.PKPageControlDirection.md- Options for the layout direction of the page indicator dots.PKPageDirection.md- Understanding the direction of page transitions._index.md- A comprehensive index for all PagerKit reference documentation.
Best Practices Summary
- Embrace Declarative UI: Use
PKPageBuilderwithForEachfor flexible and maintainable page construction. - Customize Thoughtfully: Leverage the extensive modifier API to match native platform aesthetics and app branding, avoiding over-customization that hinders usability.
- Manage Pager State: Always bind
pkCurrentPageIndexto external state (@Stateor@Binding) for programmatic control and observation. - Implement Event Handling: Utilize callbacks (e.g.,
.pkOnManualPageChange,.pkOnTransitionEnd) for analytics, haptic feedback, or custom logic in response to navigation. - Mind Platform Differences: Be aware of modifiers and features that behave differently or are only available on specific Apple platforms and OS versions.
- Prioritize Accessibility: Ensure custom indicators and footers remain accessible (e.g., with VoiceOver support).
Note: This skill is based on the comprehensive documentation for PagerKit. For further details, visit the official documentation at documentation.kamilszpak.com/documentation/pagerkit/ or the project website at kamilszpak.com/pl/pagerkit.
You Might Also Like
Related Skills

cache-components
Expert guidance for Next.js Cache Components and Partial Prerendering (PPR). **PROACTIVE ACTIVATION**: Use this skill automatically when working in Next.js projects that have `cacheComponents: true` in their next.config.ts/next.config.js. When this config is detected, proactively apply Cache Components patterns and best practices to all React Server Component implementations. **DETECTION**: At the start of a session in a Next.js project, check for `cacheComponents: true` in next.config. If enabled, this skill's patterns should guide all component authoring, data fetching, and caching decisions. **USE CASES**: Implementing 'use cache' directive, configuring cache lifetimes with cacheLife(), tagging cached data with cacheTag(), invalidating caches with updateTag()/revalidateTag(), optimizing static vs dynamic content boundaries, debugging cache issues, and reviewing Cache Component implementations.
vercel
component-refactoring
Refactor high-complexity React components in Dify frontend. Use when `pnpm analyze-component --json` shows complexity > 50 or lineCount > 300, when the user asks for code splitting, hook extraction, or complexity reduction, or when `pnpm analyze-component` warns to refactor before testing; avoid for simple/well-structured components, third-party wrappers, or when the user explicitly wants testing without refactoring.
langgenius
web-artifacts-builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use for complex artifacts requiring state management, routing, or shadcn/ui components - not for simple single-file HTML/JSX artifacts.
anthropics
frontend-design
Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, artifacts, posters, or applications (examples include websites, landing pages, dashboards, React components, HTML/CSS layouts, or when styling/beautifying any web UI). Generates creative, polished code and UI design that avoids generic AI aesthetics.
anthropics
react-modernization
Upgrade React applications to latest versions, migrate from class components to hooks, and adopt concurrent features. Use when modernizing React codebases, migrating to React Hooks, or upgrading to latest React versions.
wshobson
tailwind-design-system
Build scalable design systems with Tailwind CSS v4, design tokens, component libraries, and responsive patterns. Use when creating component libraries, implementing design systems, or standardizing UI patterns.
wshobson