Modal

TsgcHTMLComponent_Modal — render a Bootstrap 5 modal dialog with a title, body, footer buttons, sizing and a centered or static backdrop, in Delphi, C++ Builder and .NET.

TsgcHTMLComponent_Modal

A modal dialog component that emits Bootstrap 5 modal markup. Set the title, body and size, add footer buttons, then read the HTML property — or call the static Build helper for a one-liner.

Component class

TsgcHTMLComponent_Modal

Renders

Bootstrap 5 modal markup

Languages

Delphi, C++ Builder, .NET

Build it in one line, or configure it fully

Call Build(id, title, body, footer, size) for a quick modal, or create the component, add footer buttons with AddFooterButton, then read HTML. Pair it with BuildTriggerButton to open the dialog.

uses
  sgcHTML_Enums, sgcHTML_Component_Modal;

// One-line static helper (primary form):
var
  vTrigger, vDialog: string;
begin
  vTrigger := TsgcHTMLComponent_Modal.BuildTriggerButton('confirmModal',
    'Delete account', bsDanger);
  vDialog := TsgcHTMLComponent_Modal.Build('confirmModal',
    'Please confirm', 'This action cannot be undone.',
    '', msDefault);
  WebModule.Response := vTrigger + vDialog;
end;

// Or configure it fully and add custom footer buttons:
var
  oModal: TsgcHTMLComponent_Modal;
begin
  oModal := TsgcHTMLComponent_Modal.Create(nil);
  try
    oModal.ModalID := 'confirmModal';
    oModal.Title := 'Please confirm';
    oModal.Body := 'This action cannot be undone.';
    oModal.Size := msLarge;
    oModal.Centered := True;
    oModal.StaticBackdrop := True;

    oModal.AddFooterButton('Cancel', bsSecondary, True);
    oModal.AddFooterButton('Delete', bsDanger);

    WebModule.Response := oModal.HTML;   // Bootstrap modal markup
  finally
    oModal.Free;
  end;
end;
// includes: sgcHTML_Enums.hpp, sgcHTML_Component_Modal.hpp

// One-line static helper (primary form):
String trigger = TsgcHTMLComponent_Modal::BuildTriggerButton("confirmModal",
  "Delete account", bsDanger);
String dialog = TsgcHTMLComponent_Modal::Build("confirmModal",
  "Please confirm", "This action cannot be undone.",
  "", msDefault);

// Or configure it fully and add custom footer buttons:
TsgcHTMLComponent_Modal *oModal = new TsgcHTMLComponent_Modal(NULL);
try
{
  oModal->ModalID = "confirmModal";
  oModal->Title = "Please confirm";
  oModal->Body = "This action cannot be undone.";
  oModal->Size = msLarge;
  oModal->Centered = true;
  oModal->StaticBackdrop = true;

  oModal->AddFooterButton("Cancel", bsSecondary, true);
  oModal->AddFooterButton("Delete", bsDanger);

  String html = oModal->HTML;   // Bootstrap modal markup
}
__finally
{
  delete oModal;
}
using esegece.sgcWebSockets;

// One-line static helper (primary form):
string trigger = TsgcHTMLComponent_Modal.BuildTriggerButton("confirmModal",
    "Delete account", TsgcHTMLButtonStyle.bsDanger);
string dialog = TsgcHTMLComponent_Modal.Build("confirmModal",
    "Please confirm", "This action cannot be undone.",
    "", TsgcHTMLModalSize.msDefault);

// Or configure it fully and add custom footer buttons:
var modal = new TsgcHTMLComponent_Modal();
modal.ModalID = "confirmModal";
modal.Title = "Please confirm";
modal.Body = "This action cannot be undone.";
modal.Size = TsgcHTMLModalSize.msLarge;
modal.Centered = true;
modal.StaticBackdrop = true;

modal.AddFooterButton("Cancel", TsgcHTMLButtonStyle.bsSecondary, true);
modal.AddFooterButton("Delete", TsgcHTMLButtonStyle.bsDanger);

string html = modal.HTML;   // Bootstrap modal markup

Key properties & methods

The members you reach for most often.

Content

Title sets the header, Body holds the dialog content and Footer takes raw footer HTML; ModalID is the element id used by triggers.

AddFooterButton(text, style, closeOnClick) appends a styled button; pass True for closeOnClick to dismiss the modal when clicked.

Sizing

Size selects msDefault, msSmall, msLarge, msXLarge or msFullscreen via TsgcHTMLModalSize.

Behavior

Centered vertically centers the dialog, Scrollable scrolls a long body, StaticBackdrop blocks outside-click close and ShowClose toggles the header X.

Static helpers

Build(id, title, body, footer, size) returns a ready modal; BuildTriggerButton(modalID, text, style) emits a button that opens it.

Output

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

Keep exploring

All sgcHTML ComponentsBrowse the full feature matrix of 60+ components.
Download Free TrialThe 30-day trial ships the 60.HTML demo projects.
PricingSingle, Team and Site licenses with full source code.

Ready to Get Started?

Download the free trial and start building web UIs in Delphi, C++ Builder and .NET.