Simple.Toast
1.1.0
dotnet add package Simple.Toast --version 1.1.0
NuGet\Install-Package Simple.Toast -Version 1.1.0
<PackageReference Include="Simple.Toast" Version="1.1.0" />
<PackageVersion Include="Simple.Toast" Version="1.1.0" />
<PackageReference Include="Simple.Toast" />
paket add Simple.Toast --version 1.1.0
#r "nuget: Simple.Toast, 1.1.0"
#:package Simple.Toast@1.1.0
#addin nuget:?package=Simple.Toast&version=1.1.0
#tool nuget:?package=Simple.Toast&version=1.1.0
Table of contents
Quick start
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
...
xmlns:simple="clr-namespace:Simple.Toast;assembly=Simple.Toast">
- Add toast component to top-level page container:
<Grid RowDefinitions="*"
ColumnDefinitions="*">
<simple:Toast DismissDelay="2000"
ToastBackgroundColor="#2E7D32"
CornerRadius="12"
ToastPadding="16,12"
ProgressBarColor="#81C784"
Show="{Binding Show}"
Dismiss="{Binding Dismiss}"
ToastDirection="LeftToRight"
VerticalOptions="Start"
HorizontalOptions="Center"
ProgressBarDirection="Center"
ZIndex="5">
<simple:Toast.InnerContent>
<Label Text="✓ Operation completed successfully!"
TextColor="White"
FontSize="16"
FontAttributes="Bold"
HorizontalTextAlignment="Center"
VerticalTextAlignment="Center" />
</simple:Toast.InnerContent>
</simple:Toast>
</Grid>
- Add observable properties and bind them to
ShowandDismisstoast properties:
public partial class MainPageVM : ObservableObject
{
[ObservableProperty]
private bool _show = false;
[ObservableProperty]
private bool _dismiss = false;
//...
}
- Show configured toast or dismiss it in viewmodel:
public partial class MainPageVM : ObservableObject
{
//...observable properties definitions...
[RelayCommand]
public void ShowNotification()
{
Show = true;
}
[RelayCommand]
public void CancelNotification()
{
Dismiss = true;
}
//...
}
Features and limitations
Properties
Show
Show property must be bound with TwoWay binding mode. This behavior is enabled by default. Any other binding modes would cause bugs. Consider not changing Show binding mode.
Showproperty automatically resets tofalsevalue when changed totrue. Thus, one may useShow = trueto show toast multiple times.- Setting
Show = truemultiple times resets running toast animations.
Dismiss
Dismiss property must be bound with TwoWay binding mode. This behavior is enabled by default. Any other binding modes would cause bugs. Consider not changing Dismiss binding mode.
Dismissproperty is similar toShow: settingDismiss = truehides toast; it automatically resets tofalsewhen set totrue; one may useDismiss = truemultiple times.
ToastDirection
ToastDirection property supports 4 toast appearance directions:
- TopToDown (default)
- LeftToRight
- DownToTop
- RightToLeft
Important side-effect of setting ToastDirection value is that when TopToDown and DownToTop values are set, VerticalOptions property is ignored, as well as LeftToRight or RightToLeft cause HorizontalOptions value to be ignored.
IsProgressBarEnabled
Boolean property, that enables or disables toast dismiss progress bar visibility.
DismissDelay
Integer property, toast dismiss delay in milliseconds.
ProgressBarDirection
ProgressBarDirection is a enum property, supporting following 3 values:
- Center (default)
- Left
- Right
This property is used to specify progress bar move direction.
Examples
<figure> <img src="Assets/defaultToast.jpg" alt="Default toast image"> <figcaption>Default toast</figcaption> </figure>
<simple:Toast DismissDelay="2000"
ToastBackgroundColor="#2E7D32"
CornerRadius="12"
ToastPadding="16,12"
ProgressBarColor="#81C784"
Show="{Binding Show}"
Dismiss="{Binding Dismiss}"
ToastDirection="LeftToRight"
VerticalOptions="Start"
HorizontalOptions="Center"
ZIndex="5">
<simple:Toast.InnerContent>
<Label Text="✓ Operation completed successfully!"
TextColor="White"
FontSize="16"
FontAttributes="Bold"
HorizontalTextAlignment="Center"
VerticalTextAlignment="Center" />
</simple:Toast.InnerContent>
</simple:Toast>
<figure> <img src="Assets/progressBarHidden.jpg" alt="Progress bar hidden"> <figcaption>Progress bar hidden</figcaption> </figure>
<simple:Toast DismissDelay="15000"
ToastBackgroundColor="#2E7D32"
CornerRadius="12"
ToastPadding="16,12"
ProgressBarColor="#81C784"
Show="{Binding Show}"
Dismiss="{Binding Dismiss}"
ToastDirection="DownToTop"
VerticalOptions="Start"
HorizontalOptions="Center"
IsProgressBarEnabled="False"
ZIndex="5">
<simple:Toast.InnerContent>
<Label Text="✓ Operation completed successfully!"
TextColor="White"
FontSize="16"
FontAttributes="Bold"
HorizontalTextAlignment="Center"
VerticalTextAlignment="Center" />
</simple:Toast.InnerContent>
</simple:Toast>
<figure> <img src="Assets/complexToastDesign.jpg" alt="Complex toast design"> <figcaption>Complex toast design</figcaption> </figure>
<simple:Toast DismissDelay="8000"
ToastBackgroundColor="#C62828"
CornerRadius="12"
ToastPadding="16,12"
ProgressBarColor="#FFAB91"
Show="{Binding Show}"
Dismiss="{Binding Dismiss}"
ToastDirection="DownToTop"
VerticalOptions="Start"
HorizontalOptions="Center"
IsProgressBarEnabled="True"
ZIndex="5">
<simple:Toast.InnerContent>
<StackLayout Spacing="10">
<BoxView BackgroundColor="#FFCCBC"
HeightRequest="2"
WidthRequest="40"
HorizontalOptions="Center" />
<Label Text="⚠️ Operation failed"
TextColor="#FFCCBC"
FontSize="16"
FontAttributes="Bold"
HorizontalTextAlignment="Center"
VerticalTextAlignment="Center" />
<Label Text="Please check your internet connection and try again later"
TextColor="White"
FontSize="14"
HorizontalTextAlignment="Center"
LineBreakMode="WordWrap" />
<BoxView BackgroundColor="#FFCCBC"
HeightRequest="1"
WidthRequest="60"
HorizontalOptions="Center" />
</StackLayout>
</simple:Toast.InnerContent>
</simple:Toast>
Changes
version 1.1.0
- ProgressBarDirection property was added.
- Updated documentation.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0-android35.0 is compatible. net9.0-ios18.0 is compatible. net9.0-maccatalyst18.0 is compatible. net9.0-windows10.0.19041 is compatible. net10.0-android was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-windows was computed. |
-
net9.0-android35.0
- Microsoft.Maui.Controls (>= 9.0.120)
-
net9.0-ios18.0
- Microsoft.Maui.Controls (>= 9.0.120)
-
net9.0-maccatalyst18.0
- Microsoft.Maui.Controls (>= 9.0.120)
-
net9.0-windows10.0.19041
- Microsoft.Maui.Controls (>= 9.0.120)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.