Toast

TsgcHTMLComponent_Toast — renderiza una notificación toast de Bootstrap 5 con título, cuerpo, marca de tiempo, color y autocierre, colocada en pantalla por un contenedor posicionado, en Delphi, C++ Builder y .NET.

TsgcHTMLComponent_Toast

Un componente toast que emite marcado toast de Bootstrap 5. Define el título, el cuerpo y el color y luego lee la propiedad HTML — o llama al método estático Build y envuelve los toasts en un BuildContainer posicionado.

Clase de componente

TsgcHTMLComponent_Toast

Renderiza

Marcado toast de Bootstrap 5

Lenguajes

Delphi, C++ Builder, .NET

Créalo en una línea, o configúralo por completo

Llama a Build(title, body, color, timestamp) para un toast rápido y envuélvelo en BuildContainer(toasts, position), o crea el componente, define AutoHide y Delay y luego lee 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

Propiedades y métodos clave

Los miembros que más vas a usar.

Contenido

Title define el texto de la cabecera, Body el mensaje, Timestamp la pequeña etiqueta de hora e Icon un icono en línea antes del título.

Color

ColorStyle recibe un TsgcHTMLColor (como hcSuccess o hcDanger); Color acepta una cadena con el nombre de un color de Bootstrap sin formato.

Autocierre

AutoHide cierra el toast automáticamente tras Delay milisegundos (5000 por defecto); pon AutoHide en False para mantenerlo fijo.

Identidad

ToastID asigna el id del elemento para que puedas mostrar u ocultar un toast concreto desde JavaScript.

Métodos estáticos

Build(title, body, color, timestamp) devuelve un toast; BuildContainer(toasts, position) los envuelve en un toast-container fijo (TsgcHTMLToastPosition).

Salida

HTML devuelve el marcado toast de Bootstrap completo — sírvelo o asígnalo al BodyContent de una plantilla de página.

Sigue explorando

Todos los componentes sgcHTMLExplora la matriz completa de más de 60 componentes.
Descargar prueba gratuitaLa prueba de 30 días incluye los proyectos demo 60.HTML.
PreciosLicencias Single, Team y Site con código fuente completo.

¿Listo para empezar?

Descarga la prueba gratuita y empieza a crear interfaces web en Delphi, C++ Builder y .NET.