Siticone Snackbar
The SiticoneSnackbar is a lightweight, non-intrusive notification component.
It appears briefly at the bottom of the parent form (or screen) to provide contextual feedback, confirmations, or alerts without interrupting the user's workflow.
It features smooth slide-up and slide-down animations and automatically dismisses itself after a set duration.
Appearance
Customize the visual style of the snackbar to match your application theme.
| Property | Type | Description & Usage Example |
|---|---|---|
BackColor |
Color | snackbar.BackColor = Color.FromArgb(32, 32, 32); The background color of the notification popup. Defaults to a dark gray. |
MessageForeColor |
Color | snackbar.MessageForeColor = Color.White; The color of the text message displayed inside the snackbar. |
Font |
Font | snackbar.Font = new Font("Segoe UI", 10); The font used for rendering the message text. |
Behavior & Timing
Control how long the notification remains visible.
| Property | Type | Description & Usage Example |
|---|---|---|
Duration |
int | snackbar.Duration = 3000; Time in milliseconds the snackbar stays visible before sliding down. Default is 3000ms (3 seconds). |
Public Methods
// Displays the snackbar with the specified message.
// It will animate up from the bottom of the active form.
siticoneSnackbar1.ShowSnackbar("Changes saved successfully!");
Events
// 1. SnackbarShown
// Fires immediately when the ShowSnackbar method is called and the animation begins.
snackbar.SnackbarShown += (s, e) =>
{
Console.WriteLine("Notification visible.");
};
// 2. SnackbarHidden
// Fires after the slide-down animation completes and the popup closes.
snackbar.SnackbarHidden += (s, e) =>
{
Console.WriteLine("Notification dismissed.");
};
Detailed Usage Examples
Example 1: Basic Operation Confirmation
A simple usage scenario for confirming a user action like saving data.
private void BtnSave_Click(object sender, EventArgs e)
{
SaveDataToDatabase();
// Notify user without blocking UI
siticoneSnackbar1.BackColor = Color.FromArgb(40, 167, 69); // Success Green
siticoneSnackbar1.ShowSnackbar("Data saved successfully.");
}
Example 2: Async Task Notification
Triggering the snackbar after a long-running asynchronous process completes.
private async void BtnDownload_Click(object sender, EventArgs e)
{
lblStatus.Text = "Downloading...";
await Task.Delay(2000); // Simulate work
lblStatus.Text = "Ready";
// Customize for "Info" style
siticoneSnackbar1.BackColor = Color.FromArgb(0, 123, 255); // Info Blue
siticoneSnackbar1.Duration = 4000; // Stay a bit longer
siticoneSnackbar1.ShowSnackbar("Download complete. File is ready.");
}
Example 3: Error Reporting
Using the snackbar to unobtrusively report non-critical errors.
try
{
ProcessFile();
}
catch (Exception ex)
{
// Style as Error
siticoneSnackbar1.BackColor = Color.FromArgb(220, 53, 69); // Danger Red
siticoneSnackbar1.MessageForeColor = Color.White;
siticoneSnackbar1.ShowSnackbar($"Error: {ex.Message}");
}