Toast
TsgcHTMLComponent_Toast — render a Bootstrap 5 toast notification with a title, body, timestamp, color and auto-hide, placed on screen by a positioned container, in Delphi, C++ Builder and .NET.
TsgcHTMLComponent_Toast — render a Bootstrap 5 toast notification with a title, body, timestamp, color and auto-hide, placed on screen by a positioned container, in Delphi, C++ Builder and .NET.
A toast component that emits Bootstrap 5 toast markup. Set the title, body and color, then read the HTML property — or call the static Build helper and wrap toasts in a positioned BuildContainer.
TsgcHTMLComponent_Toast
Bootstrap 5 toast markup
Delphi, C++ Builder, .NET
Call Build(title, body, color, timestamp) for a quick toast and wrap it in BuildContainer(toasts, position), or create the component, set AutoHide and Delay, then read HTML.
uses
sgcHTML_Enums, sgcHTML_Component_Toast;
// One-line static helper (primary form):
var
vToast: string;
begin
vToast := TsgcHTMLComponent_Toast.Build('Saved',
'Your changes were stored.', hcSuccess, 'just now');
WebModule.Response := TsgcHTMLComponent_Toast.BuildContainer(vToast,
tpTopEnd);
end;
// Or configure it fully:
var
oToast: TsgcHTMLComponent_Toast;
begin
oToast := TsgcHTMLComponent_Toast.Create(nil);
try
oToast.ToastID := 'saveToast';
oToast.Title := 'Saved';
oToast.Body := 'Your changes were stored.';
oToast.ColorStyle := hcSuccess;
oToast.Timestamp := 'just now';
oToast.AutoHide := True;
oToast.Delay := 4000;
WebModule.Response := oToast.HTML; // Bootstrap toast markup
finally
oToast.Free;
end;
end;
// includes: sgcHTML_Enums.hpp, sgcHTML_Component_Toast.hpp
// One-line static helper (primary form):
String toast = TsgcHTMLComponent_Toast::Build("Saved",
"Your changes were stored.", hcSuccess, "just now");
String html = TsgcHTMLComponent_Toast::BuildContainer(toast, tpTopEnd);
// Or configure it fully:
TsgcHTMLComponent_Toast *oToast = new TsgcHTMLComponent_Toast(NULL);
try
{
oToast->ToastID = "saveToast";
oToast->Title = "Saved";
oToast->Body = "Your changes were stored.";
oToast->ColorStyle = hcSuccess;
oToast->Timestamp = "just now";
oToast->AutoHide = true;
oToast->Delay = 4000;
String body = oToast->HTML; // Bootstrap toast markup
}
__finally
{
delete oToast;
}
using esegece.sgcWebSockets;
// One-line static helper (primary form):
string toast = TsgcHTMLComponent_Toast.Build("Saved",
"Your changes were stored.", TsgcHTMLColor.hcSuccess, "just now");
string html = TsgcHTMLComponent_Toast.BuildContainer(toast,
TsgcHTMLToastPosition.tpTopEnd);
// Or configure it fully:
var t = new TsgcHTMLComponent_Toast();
t.ToastID = "saveToast";
t.Title = "Saved";
t.Body = "Your changes were stored.";
t.ColorStyle = TsgcHTMLColor.hcSuccess;
t.Timestamp = "just now";
t.AutoHide = true;
t.Delay = 4000;
string body = t.HTML; // Bootstrap toast markup
The members you reach for most often.
Title sets the header text, Body the message, Timestamp the small time label and Icon an inline icon before the title.
ColorStyle takes a TsgcHTMLColor (such as hcSuccess or hcDanger); Color accepts a raw Bootstrap color name string.
AutoHide dismisses the toast automatically after Delay milliseconds (default 5000); set AutoHide to False to keep it pinned.
ToastID assigns the element id so you can show or hide a specific toast from JavaScript.
Build(title, body, color, timestamp) returns one toast; BuildContainer(toasts, position) wraps them in a fixed toast-container (TsgcHTMLToastPosition).
HTML returns the complete Bootstrap toast markup — serve it, or assign it to a page template's BodyContent.