Skip to main content

Toaster configuration

Toaster options can be modified globally on the client side. The configured values apply to all toasts displayed afterward. Without explicit configuration, Lagoon uses the default values of LgToastrOptions.

Global configuration​

In the Client project, configure the options in Main.cs, via OnConfigureBehavior.

Main.cs
public class Main : LgCustomApplication
{
protected override void OnConfigureBehavior(ApplicationBehavior app)
{
// Applies a common position and duration to all toasts.
app.Toastr.Position = Position.TopRight;
app.Toastr.ProgressBar = false;
app.Toastr.TimeOut = 5000;
}
}

Available options​

OptionTypeDefaultDescription
CloseButtonbooltrueShows a close button.
DebugboolfalseEnables debug mode for the toast library.
NewestOnTopboolfalseDisplays new messages above previous ones if the value is true.
ProgressBarbooltrueShows a progress bar indicating the remaining display duration.
PreventDuplicatesboolfalsePrevents displaying two messages with the same content simultaneously.
PositionPositionPosition.TopRightDefines the position of toasts.
PositionClassstringComputedCSS class computed from Position.
OnclickstringnullJavaScript callback called when clicking on a toast.
ShowDurationint300Duration of the show animation, in milliseconds.
HideDurationint1000Duration of the hide animation, in milliseconds.
TimeOutint5000Delay before auto-closing non-error messages.
ExtendedTimeOutint1000Delay before closing after hover.
ShowEasingstring"swing"CSS easing function for the show animation.
HideEasingstring"linear"CSS easing function for the hide animation.
ShowMethodstring"fadeIn"Animation used for showing.
HideMethodstring"fadeOut"Animation used for hiding.

Available positions​

ValueComputed CSS class
Position.TopLefttoast-top-left
Position.TopRighttoast-top-right
Position.BottomLefttoast-bottom-left
Position.BottomRighttoast-bottom-right
Position.TopCentertoast-top-center
Position.BottomCentertoast-bottom-center
info

These options are global behavior parameters. Toasts are displayed from a page or component using methods inherited from LgComponentBase, for example ShowSuccess("#OrderSaved").