https://github.com/danielsaidi/scrollkit
ScrollKit is a SwiftUI SDK that adds powerful scroll features, like offset tracking and a header view that stretches & transforms as you pull down, and sticks to the top when you scroll.
https://github.com/danielsaidi/scrollkit
ios macos scrollview sticky-header swiftui tvos visionos watchos
Last synced: 2 months ago
JSON representation
ScrollKit is a SwiftUI SDK that adds powerful scroll features, like offset tracking and a header view that stretches & transforms as you pull down, and sticks to the top when you scroll.
- Host: GitHub
- URL: https://github.com/danielsaidi/scrollkit
- Owner: danielsaidi
- License: mit
- Created: 2023-02-04T13:24:58.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-05-02T09:26:09.000Z (2 months ago)
- Last Synced: 2025-05-02T10:34:30.791Z (2 months ago)
- Topics: ios, macos, scrollview, sticky-header, swiftui, tvos, visionos, watchos
- Language: Swift
- Homepage:
- Size: 14.6 MB
- Stars: 788
- Watchers: 5
- Forks: 31
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
![]()
# ScrollKit
ScrollKit is a SwiftUI SDK that adds powerful scroll features, like offset tracking and a header view that stretches & transforms as you pull down, and sticks to the top when you scroll.
![]()
ScrollKit works on all major Apple platforms and is designed to be easy to use. It doesn't use the new `ScrollView` APIs for backwards compatibility reasons, but will eventually do so.
## Installation
ScrollKit can be installed with the Swift Package Manager:
```
https://github.com/danielsaidi/ScrollKit.git
```## Getting started
ScrollKit has a `ScrollViewWithOffsetTracking` that can detect scrolling on all OS versions:
```swift
ScrollViewWithOffsetTracking { offset in
print(offset)
} content: {
// Add your scroll content here, e.g. a `LazyVStack`
}
```ScrollKit has a `ScrollViewWithStickyHeader` that makes it easy to set up a stretchy, sticky header:
```swift
import SwiftUI
import ScrollKitstruct MyView: View {
@State
private var scrollOffset = CGPoint.zero@State
private var visibleRatio = CGFloat.zerovar body: some View {
ScrollViewWithStickyHeader(
header: stickyHeader, // A header view
headerHeight: 250, // The resting header height
headerMinHeight: 150, // The minimum header height
headerStretch: false, // Disables the stretch effect
contentCornerRadius: 20, // An optional corner radius mask
onScroll: handleScroll // An optional scroll handler action
) {
// Add your scroll content here, e.g. a `LazyVStack`
}
}func handleScroll(_ offset: CGPoint, visibleHeaderRatio: CGFloat) {
self.scrollOffset = offset
self.visibleRatio = visibleHeaderRatio
}func stickyHeader() -> some View {
ZStack {
Color.red
ScrollViewHeaderGradient() // By default a dark gradient
Text("Scroll offset: \(scrollOffset.y)")
}
}
}
```For more information, please see the [getting started guide][Getting-Started].
## Documentation
The [online documentation][Documentation] has more information, articles, code examples, etc.
## Demo Application
The demo app lets you explore the library. To try it out, just open and run the `Demo` project.
## Support my work
You can [sponsor me][Sponsors] on GitHub Sponsors or [reach out][Email] for paid support, to help support my [open-source projects][OpenSource].
Your support makes it possible for me to put more work into these projects and make them the best they can be.
## Contact
Feel free to reach out if you have questions or want to contribute in any way:
* Website: [danielsaidi.com][Website]
* E-mail: [[email protected]][Email]
* Bluesky: [@[email protected]][Bluesky]
* Mastodon: [@[email protected]][Mastodon]## License
ScrollKit is available under the MIT license. See the [LICENSE][License] file for more info.
[Email]: mailto:[email protected]
[Website]: https://danielsaidi.com
[GitHub]: https://github.com/danielsaidi
[OpenSource]: https://danielsaidi.com/opensource
[Sponsors]: https://github.com/sponsors/danielsaidi[Bluesky]: https://bsky.app/profile/danielsaidi.bsky.social
[Mastodon]: https://mastodon.social/@danielsaidi
[Twitter]: https://twitter.com/danielsaidi[Documentation]: https://danielsaidi.github.io/ScrollKit/
[Getting-Started]: https://danielsaidi.github.io/ScrollKit/documentation/scrollkit/getting-started-article
[License]: https://github.com/danielsaidi/ScrollKit/blob/master/LICENSE