- August 28, 2025
- Mins Read
Customize confetti animations.
š Examples
TheĀ Swift Package ManagerĀ is a tool for managing the distribution of Swift code. Itās integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.
To integrateĀ ConfettiSwiftUIĀ into your Xcode project using Xcode 12, specify it inĀ File > Swift Packages > Add Package Dependency...:
https://github.com/simibac/ConfettiSwiftUI.git, :branch=”master”
Manually
If you prefer not to use any of dependency managers, you can integrateĀ ConfettiSwiftUIĀ into your project manually. PutĀ Sources/ConfettiSwiftUIĀ folder in your Xcode project. Make sure to enableĀ Copy items if neededĀ andĀ Create groups.
š§³ Requirements
š Usage
First, addĀ import ConfettiSwiftUIĀ on everyĀ swiftĀ file you would like to useĀ ConfettiSwiftUI. Define a integer as a state varable which is responsible for triggering the animation. Any change to that variable will span a new animation (increment and decrement).
import ConfettiSwiftUI
import SwiftUI
struct ContentView: View {
@State private var trigger: Int = 0
var body: some View {
Button(“š”) {
trigger += 1
}
.confettiCannon(trigger: $trigger)
}
}
| parameter | type | description | default |
|---|---|---|---|
| trigger | Binding | on any change of this variable triggers the animation | 0 |
| num | Int | amount of confettis | 20 |
| confettis | [ConfettiType] | list of shapes and text | [.shape(.circle), .shape(.triangle), .shape(.square), .shape(.slimRectangle), .shape(.roundedCross)] |
| colors | [Color] | list of colors applied to the default shapes | [.blue, .red, .green, .yellow, .pink, .purple, .orange] |
| confettiSize | CGFloat | size that confettis and emojis are scaled to | 10.0 |
| rainHeight | CGFloat | vertical distance that confettis pass | 600.0 |
| fadesOut | Bool | size that confettis and emojis are scaled to | true |
| opacity | Double | maximum opacity during the animation | 1.0 |
| openingAngle | Angle | boundary that defines the opening angle in degrees | Angle.degrees(60) |
| closingAngle | Angle | boundary that defines the closing angle in degrees | Angle.degrees(120) |
| radius | CGFloat | explosion radius | 300.0 |
| repetitions | Int | number of repetitions for the explosion | 1 |
| repetitionInterval | Double | duration between the repetitions | 1.0 |
| hapticFeedback | Bool | haptic feedback on each confetti explosion | true |
You can use the configurator app inĀ demo project hereĀ to configure your desired animation or get inspired by one of the many examples.
.confettiCannon(trigger: $trigger, colors: [.red, .black], confettiSize: 20)
.confettiCannon(trigger: $trigger, repetitions: 3, repetitionInterval: 0.7)
.confettiCannon(trigger: $trigger, num: 50, openingAngle: Angle(degrees: 0), closingAngle: Angle(degrees: 360), radius: 200)
.confettiCannon(trigger: $trigger, confettis: [.text(“ā¤ļø”), .text(“š”), .text(“š”), .text(“š§””)])
.confettiCannon(trigger: $trigger, num:1, confettis: [.text(“š©”)], confettiSize: 20, repetitions: 100, repetitionInterval: 0.1)
.confettiCannon(trigger: $trigger, num:1, confettis: [.text(“šµ”), .text(“š¶”), .text(“š·”), .text(“š“”)], confettiSize: 30, repetitions: 50, repetitionInterval: 0.1)
.confettiCannon(trigger: $trigger8, confettis: [.image(“arb”), .image(“eth”), .image(“btc”), .image(“op”), .image(“link”), .image(“doge”)], confettiSize: 20)
This package provides you with an easy way to show tooltips over any SwiftUI view, since Apple does not provide ...
SimpleToast is a simple, lightweight, flexible and easy to use library to show toasts / popup notifications inside iOS or ...
Create Toast Views with Minimal Effort in SwiftUI Using SSToastMessage. SSToastMessage enables you to effortlessly add toast notifications, alerts, and ...