You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ToastKit is a lightweight and fully customizable Swift package that helps you display informative toast messages in your app. Itโs easy to use, supports
various built-in toast styles like success, warning, info, error, with icons.... and also allows full customization for your specific needs.
You can quickly use ready-made toasts or create your own custom toast view with complete control over layout, colors, animations, icons, and more.
Features ๐
Full Customization
Glass Effect
Max Width Support
Custom Icons & SF Symbols
Auto Dismiss
Transition Types
Flexible Layout Direction
Text Styling Options
Shadow Customization
Corner Radius Control
Optional Subtitle
Adaptive Stack Alignment
Smooth Animations
Manual Close Button
Responsive Design
GlassEffect
VStack{}.frame(maxWidth:.infinity,maxHeight:.infinity)
//simple usage
.glassToast(isVisible:$isVisible,title:title)
//with full parameters
.glassToast(isVisible:$isVisible2,title:title,subtitle:"if you have iOS 26 you can use this toast",glassColor:.red.opacity(0.5),titleFontColor:.black,subtitleFontColor:.black,maxWidth:false,transitionType:.custom(.asymmetric(insertion:.move(edge:.trailing),removal:.move(edge:.leading)).combined(with:.opacity)),animation:.smooth,vDirection:.bottom)
Configuration โ๏ธ
Parameter
Type
Default Value
Description
isVisible
Binding
โ
Binding to control visibility.
title
String
โ
The main message displayed in the toast.
subtitle
String
""
Subtitle text for additional info.
titleFontColor
Color
.white
Font color of the title.
subtitleFontColor
Color
.white
Font color of the subtitle.
transitionType
ToastTransitionType
.move(edge: .top)
The transition animation for how the toast appears/disappears.
VStack{}.successToast(isVisible:$isVisible,title:"success full width",toastColor:.success,animation:.snappy,titleFontColor:.white,maxWidth:false).warningToast(isVisible:$isVisible,title:"warning full width",toastColor:.warning,animation:.snappy,titleFontColor:.white,maxWidth:false).errorToast(isVisible:$isVisible,title:"error full width",toastColor:.error,animation:.snappy,titleFontColor:.white,maxWidth:false).infoToast(isVisible:$isVisible,title:"info full width",toastColor:.info,animation:.snappy,titleFontColor:.white,maxWidth:false)
Configuration โ๏ธ
Parameter
Type
Default Value
Description
isVisible
Binding
โ
Binding to control visibility.
title
String
โ
The main message displayed in the toast.
toastColor
ToastColorTypes
.success / .warning / .error / .info
The visual style or color theme of the toast .
animation
Animation
.snappy
Animation used to present and dismiss the toast.
titleFontColor
Color
.white
The color of the toast message text.
maxWidth
Bool
false
Whether the toast should stretch to the maximum width.
The color type or style of the toast (.success, .error, .info, .warning, .custom(Color)).
animation
Animation
.snappy
Animation used to present and dismiss the toast.
hDirection
HorizontalDirection
.trailing
Slide from horizontal edge (.leading or .trailing).
vDirection
VerticalDirection
.top
Vertical position of the toast (.top or .bottom).
titleFontColor
Color
.white
The color of the toast message text.
maxWidth
Bool
false
If true, toast stretches to maximum available width.
Toast with SF Symbol
simple toast
VStack{}.toastWithSFSymbol(isVisible:$isVisivble,title:"Toast with SF symbol",sfSymbolName:"sun.max")
with full parameters
VStack{}.toastWithSFSymbol(isVisible:$isVisivble,title:"Toast with SF symbol",toastColor:.custom(.indigo),titleFontColor:.white,sfSymbolName:"sun.max",sfSymbolSize:18,sfSymbolColor:.black,transitionType:.scale,animation:.smooth,vDirection:.top,maxWidth:false,layoutDirection:.leftToRight)
Configuration โ๏ธ
Parameter
Type
Default Value
Description
isVisible
Binding
โ
Binding to control visibility.
title
String
โ
The main message displayed in the toast.
toastColor
ToastColorTypes
.success
The color type or style of the toast (.success, .error, .info, .warning, .custom(Color)).
titleFontColor
Color
.white
The color of the toast message text.
sfSymbolName
String?
nil
Optional name of an SF Symbol.
sfSymbolSize
CGFloat?
24
Size of the SF Symbol icon.
sfSymbolColor
Color?
.white
Color of the SF Symbol icon.
transitionType
ToastTransitionType
.move(edge: .top)
The transition animation for how the toast appears/disappears.
animation
Animation
.snappy
Animation used to present and dismiss the toast.
vDirection
VerticalDirection
.top
Vertical position of the toast (.top or .bottom).
maxWidth
Bool
false
If true, toast takes maximum available width.
layoutDirection
LayoutDirection
.leftToRight
Layout direction of content (.leftToRight or .rightToLeft).
The color type or style of the toast (.success, .error, .info, .warning, .custom(Color)).
iconName
String?
nil
Optional name of a custom icon (from asset).
iconSize
CGFloat?
24
Size of the custom icon.
iconColor
Color?
.white
Color of the custom icon.
transitionType
ToastTransitionType
.move(edge: .top)
The transition animation for how the toast appears/disappears.
animation
Animation
.snappy
Animation used to present and dismiss the toast.
vDirection
VerticalDirection
.top
Vertical position of the toast (.top or .bottom).
titleFontColor
Color
.white
The color of the toast message text.
maxWidth
Bool
false
If true, toast takes maximum available width.
layoutDirection
LayoutDirection
.leftToRight
Layout direction of content (.leftToRight or .rightToLeft).
๐ Toast Stack
With ToastStackManager, you can show toasts at the same time!ย
Certainly, you can utilize toast stacks from your view model. Hereโs an example:
// in your ViewModel
importToastKitimportCombinefinalclassViewModel:ObservableObject{lettoastManager:ToastStackManagerinit(toastManager:ToastStackManager=ToastStackManager()){self.toastManager=toastManager}@MainActorfuncfoo(){
// Your logic
toastManager.show(title:"foo success toast",toastColor:.success,autoDisappearDuration:3.0)
// Your logic
toastManager.show(title:"foo info toast",toastColor:.info)}}
in your view
importToastKitimportSwiftUIstructProfileView:View{@StateObjectprivatevarvm:ViewModelinit(vm:ViewModel=ViewModel()){_vm=StateObject(wrappedValue:vm)}varbody:someView{ZStack{
// Your view
ToastStackView(vm:vm.toastManager)
// Alternatively, you can utilize it with a custom transition.
ToastStackView(vm:vm.toastManager,transitionType:.move(edge:.trailing).combined(with:.opacity))}}}
ToastStackView Configuration โ๏ธ
Parameter
Type
Default Value
Description
title
String
-
The main message displayed in the toast.
toastColor
ToastColorTypes
-
The color type or style of the toast.
autoDisappearDuration
TimeInterval
2.0
Duration before toast disappears.
ToastStackManager Configuration โ๏ธ
Parameter
Type
Default Value
Description
vm
ToastStackManager
-
The view model that manages
transitionType
AnyTransition
-
Transition animation for appearing/disappearing.
โ ๏ธ Alternatively, you can utilize the .toast method to construct a fully customizable toast by specifying the following parameters: