Components / Feedback

Toast stack

Notifications that enter with a spring, reflow around a dismissal, and cancel their lifetime tasks when removed.

iOS 17+Swift 6MITView source
Toast stack, rendered by SwiftUI on an iPhone simulator
Recorded in the iOS simulator

Real SwiftUI, captured on an iPhone 17 Pro simulator. Run the native gallery

Installation

Install the native Swift CLI, then add the component to your app.

Terminal
hugsy add toast-stack

Prefer to copy it yourself? Open the complete Swift file and add it to your iOS app target in Xcode. No package dependency is required.

Usage

SwiftUI
@State private var toasts = HugsyToasts()

HugsyToastStack(toasts: toasts)

Button("Save") {
  toasts.show("Changes saved", duration: .seconds(5))
}

Keep a HugsyToasts instance in @State and overlay HugsyToastStack inside your safe area. At most four notifications remain visible. Each mounted row owns its timeout task, which is cancelled when that row disappears.

API reference

Toast stack parameters
ParameterType & behaviorDefault
toastsHugsyToasts

Keep this main-actor observable model in @State.

Required
show(_:symbol:duration:)HugsyToasts method

Adds a toast at the front, keeping at most four. The symbol defaults to checkmark.circle.fill.

5 seconds
dismiss(_:)(UUID) -> Void

Removes the matching notification. Repeated dismissal is safe.

None

Interaction

Add a notification, then dismiss one from the stack. New notifications expire independently.

EmptyEnteringStackedDismissingExpired

Accessibility

Each notification has a labeled dismiss button. Reduce Motion uses opacity rather than sliding transitions. Keep important errors in persistent screen content instead of relying on a timed toast.

Test with VoiceOver, Dynamic Type, and Reduce Motion on a physical device before shipping. The gallery demonstrates the interaction, not every application-specific content state.