Notification

TsgcHTMLComponent_Notification — render a bell-icon dropdown notification centre with an unread badge, built from a collection of notification items, in Delphi, C++ Builder and .NET.

TsgcHTMLComponent_Notification

A notification-centre component that emits a Bootstrap 5 dropdown. Add items to its Items collection (or call AddNotification), then read the HTML property — the unread UnreadCount drives the badge.

Component class

TsgcHTMLComponent_Notification

Renders

Bootstrap 5 dropdown markup

Languages

Delphi, C++ Builder, .NET

Create it, add notifications, render it

Set Title and MaxVisible, call AddNotification(title, message, color, timestamp) for each entry, then read HTML. The unread count populates the badge automatically.

uses
  sgcHTML_Enums, sgcHTML_Component_Notification;

var
  oNotif: TsgcHTMLComponent_Notification;
begin
  oNotif := TsgcHTMLComponent_Notification.Create(nil);
  try
    oNotif.Title := 'Notifications';
    oNotif.MaxVisible := 5;
    oNotif.ShowBadge := True;

    oNotif.AddNotification('New order',
      'Order #1042 was placed.', hcSuccess, '2 min ago');
    oNotif.AddNotification('Payment failed',
      'Invoice #88 could not be charged.', hcDanger, '10 min ago');

    WebModule.Response := oNotif.HTML;   // bell dropdown + badge
  finally
    oNotif.Free;
  end;
end;

// Or add items via the Items collection directly:
with oNotif.Items.Add do
begin
  Title := 'Welcome';
  Message := 'Your account is ready.';
  Color := hcInfo;
end;
// includes: sgcHTML_Enums.hpp, sgcHTML_Component_Notification.hpp

TsgcHTMLComponent_Notification *oNotif = new TsgcHTMLComponent_Notification(NULL);
try
{
  oNotif->Title = "Notifications";
  oNotif->MaxVisible = 5;
  oNotif->ShowBadge = true;

  oNotif->AddNotification("New order",
    "Order #1042 was placed.", hcSuccess, "2 min ago");
  oNotif->AddNotification("Payment failed",
    "Invoice #88 could not be charged.", hcDanger, "10 min ago");

  String html = oNotif->HTML;   // bell dropdown + badge
}
__finally
{
  delete oNotif;
}

// Or add items via the Items collection directly:
TsgcHTMLNotificationItem *item = oNotif->Items->Add();
item->Title = "Welcome";
item->Message = "Your account is ready.";
item->Color = hcInfo;
using esegece.sgcWebSockets;

var notif = new TsgcHTMLComponent_Notification();
notif.Title = "Notifications";
notif.MaxVisible = 5;
notif.ShowBadge = true;

notif.AddNotification("New order",
    "Order #1042 was placed.", TsgcHTMLColor.hcSuccess, "2 min ago");
notif.AddNotification("Payment failed",
    "Invoice #88 could not be charged.", TsgcHTMLColor.hcDanger, "10 min ago");

string html = notif.HTML;   // bell dropdown + badge

// Or add items via the Items collection directly:
var item = notif.Items.Add();
item.Title = "Welcome";
item.Message = "Your account is ready.";
item.Color = TsgcHTMLColor.hcInfo;

Key properties & methods

The members you reach for most often.

Items

Items is a TsgcHTMLNotificationItems collection; each TsgcHTMLNotificationItem has Title, Message, Timestamp, Color, Icon, Href and Read.

Add notifications

AddNotification(title, message, color, timestamp) appends an item and defaults the timestamp to the current time when omitted.

Unread badge

UnreadCount counts items whose Read is False; ShowBadge toggles the red pill and GetBadgeHTML returns just the badge markup.

Title sets the dropdown heading, EmptyText the placeholder when there are no items and BellIcon the trigger glyph.

Limits

MaxVisible caps how many items render (default 5), with a "View all" link when more exist; NotificationID assigns the element id.

Output

HTML returns the complete bell-icon dropdown with its scoped CSS — 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.