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

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.

Klasa komponentu

TsgcHTMLComponent_Toast

Renderuje

Bootstrap 5 toast markup

Języki

Delphi, C++ Builder, .NET

Build it in one line, or configure it fully

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

Kluczowe właściwości i metody

Składniki, po które sięgasz najczęściej.

Content

Title sets the header text, Body the message, Timestamp the small time label and Icon an inline icon before the title.

Color

ColorStyle takes a TsgcHTMLColor (such as hcSuccess or hcDanger); Color accepts a raw Bootstrap color name string.

Auto-hide

AutoHide dismisses the toast automatically after Delay milliseconds (default 5000); set AutoHide to False to keep it pinned.

Identity

ToastID assigns the element id so you can show or hide a specific toast from JavaScript.

Static helpers

Build(title, body, color, timestamp) returns one toast; BuildContainer(toasts, position) wraps them in a fixed toast-container (TsgcHTMLToastPosition).

Output

HTML returns the complete Bootstrap toast markup — serve it, or assign it to a page template's BodyContent.

Poznawaj dalej

Wszystkie komponenty sgcHTMLPrzejrzyj pełną matrycę funkcji 60+ komponentów.
Pobierz bezpłatną wersję próbną30-dniowa wersja próbna zawiera projekty demonstracyjne 60.HTML.
CennikLicencje Single, Team i Site z pełnym kodem źródłowym.

Gotowy, aby zacząć?

Pobierz bezpłatną wersję próbną i zacznij budować interfejsy webowe w Delphi, C++ Builder i .NET.