A lightweight, customizable toast notification library for SwiftUI applications, designed to provide elegant and user-friendly notifications with minimal setup.
- 🎯 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)
Add the following to your Package.swift
file:
dependencies: [
.package(url: "https://github.com/yourusername/Toasty.git", from: "1.0.0")
]
- Add the
.toastable()
modifier to your root view:
import Toasty
@main
struct MyApp: App {
var body: some Scene {
WindowGroup {
ContentView()
.toastable() // Add this modifier
}
}
}
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)
}
}
}
.info
- For general information.success
- For successful operations.warning
- For warning messages.error
- For error messages
Adjust toast position using the alignment parameter:
ContentView()
.toastable(alignment: .bottom) // Show toasts at the bottom
- iOS 15.0+
- macOS 12.0+
- Xcode 15.0+
- Swift 5.5+
We welcome contributions! Please follow these steps:
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Write tests for your changes
- Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License - see the LICENSE file for details.
Annurdien Rasyid
- GitHub: @annurdien
- LinkedIn: Annurdien Rasyid
Made with ❤️ by Annurdien Rasyid