Swiftpack.co - Tunous/LongPressButton as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Tunous.
Tunous/LongPressButton 1.1.0
A SwiftUI button that initiates action on tap or long press.
⭐️ 1
🕓 3 weeks ago
.package(url: "https://github.com/Tunous/LongPressButton.git", from: "1.1.0")



A SwiftUI button that initiates action on tap or long press.


Create LongPressButton similar to how you would create a regular Button passing it a title, action to perform on tap and an action to perform on long press.

LongPressButton("Tap or long press me") { 
    // Tapped
} longPressAction: { 
    // Long pressed

Additionally you can configure minimum long press duration, maximum finger travel distance or provide custom label.

LongPressButton(minimumDuration: 0.5, maximumDistance: 10) { 
    // Tapped
} longPressAction: { 
    // Long pressed
} label: {
    Image(systemName: "plus")


Swift Package Manager

Add the following to the dependencies array in your "Package.swift" file:

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

Or add https://github.com/Tunous/LongPressButton.git, to the list of Swift packages for any project in Xcode.


Supporting Both Tap and Long Press on a Button in SwiftUI by Peter Steinberger - Great article with few potential solution on how to create button with long press action. Unfortunately none of them worked correctly for my use case.


Stars: 1
Last commit: 3 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

3 weeks ago
  • Added sample app
  • Change order of longPressAction and action parameters
  • Made action parameter required

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics