Toasty

0.1.10

Toast made easy!
annurdien/Toasty

What's New

v0.1.10

2025-04-21T18:09:36Z

Toasty Logo

Toasty

Swift 5.5+ iOS 15.0+ macOS 12.0+ MIT

A lightweight, customizable toast notification library for SwiftUI applications, designed to provide elegant and user-friendly notifications with minimal setup.

Toasty Demo

✨ Features

  • 🎯 Simple and intuitive API
  • 🎨 Four built-in toast types (info, success, warning, error)
  • ⚡️ Smooth animations and transitions
  • 🔄 Auto-dismissal with customizable duration
  • 👆 Tap to dismiss
  • ♿️ Accessibility support
  • 📱 Safe area aware
  • 🎭 Flexible positioning (top, bottom)

📦 Installation

Swift Package Manager

Add the following to your Package.swift file:

dependencies: [
    .package(url: "https://github.com/yourusername/Toasty.git", from: "1.0.0")
]

🚀 Usage

Basic Setup

  1. Add the .toastable() modifier to your root view:
import Toasty

@main
struct MyApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
                .toastable() // Add this modifier
        }
    }
}

Show Toasts

You can use the @Toast property wrapper (recommended) or @EnvironmentObject:

struct ContentView: View {
    @Toast private var toast
    
    var body: some View {
        Button("Show Toast") {
            // Simple usage
            toast.show(message: "Hello, World!")
            
            // With type and duration
            toast.show(
                message: "Operation successful!",
                type: .success,
                duration: 3.0
            )
            
            // Using ToastData
            let customToast = ToastData(
                message: "Custom toast",
                type: .warning,
                duration: 2.0
            )
            toast.show(toast: customToast)
        }
    }
}

Toast Types

  • .info - For general information
  • .success - For successful operations
  • .warning - For warning messages
  • .error - For error messages

Customization

Adjust toast position using the alignment parameter:

ContentView()
    .toastable(alignment: .bottom) // Show toasts at the bottom

⚙️ Requirements

  • iOS 15.0+
  • macOS 12.0+
  • Xcode 15.0+
  • Swift 5.5+

👥 Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Write tests for your changes
  4. Commit your changes (git commit -m 'Add amazing feature')
  5. Push to the branch (git push origin feature/amazing-feature)
  6. Open a Pull Request

For major changes, please open an issue first to discuss what you would like to change.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

👨‍💻 Author

Annurdien Rasyid


Made with ❤️ by Annurdien Rasyid

Description

  • Swift Tools 5.7.0
View More Packages from this Author

Dependencies

  • None
Last updated: Sun Apr 27 2025 13:21:57 GMT-0900 (Hawaii-Aleutian Daylight Time)