Toast

TsgcHTMLComponent_Toast — renderize uma notificação toast do Bootstrap 5 com título, corpo, carimbo de tempo, cor e ocultação automática, posicionada na tela por um contêiner posicionado, em Delphi, C++ Builder e .NET.

TsgcHTMLComponent_Toast

Um componente toast que emite markup toast do Bootstrap 5. Defina o título, o corpo e a cor e então leia a propriedade HTML — ou chame o helper estático Build e envolva os toasts em um BuildContainer posicionado.

Classe do componente

TsgcHTMLComponent_Toast

Renderiza

Markup de toast do Bootstrap 5

Linguagens

Delphi, C++ Builder, .NET

Construa em uma linha, ou configure-o por completo

Chame Build(title, body, color, timestamp) para um toast rápido e envolva-o em BuildContainer(toasts, position), ou crie o componente, defina AutoHide e Delay e então leia 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

Principais propriedades & métodos

Os membros que você usa com mais frequência.

Conteúdo

Title define o texto do cabeçalho, Body a mensagem, Timestamp o pequeno rótulo de tempo e Icon um ícone inline antes do título.

Cor

ColorStyle recebe um TsgcHTMLColor (como hcSuccess ou hcDanger); Color aceita uma string de nome de cor Bootstrap bruta.

Ocultação automática

AutoHide dispensa o toast automaticamente após Delay milissegundos (padrão 5000); defina AutoHide como False para mantê-lo fixado.

Identidade

ToastID atribui o id do elemento para que você possa mostrar ou ocultar um toast específico a partir do JavaScript.

Helpers estáticos

Build(title, body, color, timestamp) retorna um toast; BuildContainer(toasts, position) os envolve em um toast-container fixo (TsgcHTMLToastPosition).

Saída

HTML retorna o markup completo do toast Bootstrap — sirva-o ou atribua-o ao BodyContent de um template de página.

Continue explorando

Todos os Componentes sgcHTMLExplore a matriz completa de recursos com mais de 60 componentes.
Baixar Versão de Avaliação GratuitaA avaliação de 30 dias inclui os projetos de demonstração 60.HTML.
PreçosLicenças Single, Team e Site com código-fonte completo.

Pronto para Começar?

Baixe a versão de avaliação gratuita e comece a construir UIs web em Delphi, C++ Builder e .NET.