Programming language: Swift
License: MIT License
Tags: UI     Alert    

Toast-Swift alternatives and similar libraries

Based on the "Alert" category.
Alternatively, view Toast-Swift alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of Toast-Swift or a related project?

Add another 'Alert' Library



Codacy Badge

A Swift Toast view - iOS 14 style - built with UIKit. ๐Ÿž


Swift Package Manager

You can use The Swift Package Manager to install Toast-Swift by adding the description to your Package.swift file:

import PackageDescription

let package = Package(
    name: "YOUR PROJECT NAME",
    targets: [],
    dependencies: [
        .package(url: "https://github.com/BastiaanJansen/Toast-Swift", from: "1.0.0")

Next, add Toast-Swift to your targets dependencies:

    name: "YOUR PROJECT NAME",
    dependencies: [


To create a simple text based toast:

let toast = Toast.text("Safari pasted from Notes")

Or add a subtitle:

let toast = Toast.text("Safari pasted from Notes", subtitle: "A few seconds ago")

If you want to add an icon, use the default method to construct a toast:

let toast = Toast.default(
    image: UIImage(systemname: "airpodspro")!,
    title: "Airpods Pro",
    subtitle: "Connected"

Want to use a different layout, but still use the Apple style? Create your own view and inject it into the AppleToastView class when creating a custom toast:

let customView: UIView = // Custom view

let appleToastView = AppleToastView(child: customView)

let toast = Toast.custom(view: appleToastView)

Custom toast view

Don't like the default Apple'ish style? No problem, it is also possible to use a custom toast view with the custom method. Firstly, create a class that confirms to the ToastView protocol:

class CustomToastView : UIView, ToastView {
    private let text: String

    public init(text: String) {
        self.text = text

    func viewDidLoad() {
        // View is added to superview, create and style layout and add constraints

Use your custom view with the custom construct method on Toast:

let customToastView: ToastView = CustomToastView(text: "Safari pasted from Notes")

let toast = Toast.custom(view: customToastView)

The show method accepts several optional parameters. haptic of type UINotificationFeedbackGenerator.FeedbackType to use haptics and after of type TimeInterval to show the toast after a certain amount of time:

toast.show(haptic: .success, after: 1)

Configuration options

The text, default and custom methods support custom configuration options. The following options are available:

Name Type Default
autoHide Bool true
displayTime TimeInterval 4
swipeUpToHide Bool true
animationTime TimeInterval 0.2
removeFromView Bool false
view UIView nil
onTap (Toast) -> () nil
let config = ToastConfiguration(
    autoHide: true,
    displayTime: 5,
    swipeUpToHide: true,
    animationTime: 0.2,
    removeFromView: true, // When enabled, you can only call .show() once. After the toast is closed, it will be removed from the view.
    onTap: { toast in

let toast = toast.text("Safari pasted from Notes", config: config)

*Note that all licence references and agreements mentioned in the Toast-Swift README section above are relevant to that project's source code only.