ChatBox Component — sgcHTML | eSeGeCe

ChatBox

TsgcHTMLComponent_ChatBox — a card-style chat bubble box with left/right messages, avatars, an input bar and an animated typing indicator, in Delphi, C++ Builder and .NET.

TsgcHTMLComponent_ChatBox

A lightweight chat component that emits a Bootstrap 5 card with scrollable message bubbles and an optional input bar. Add messages, set a few properties, then read the HTML property.

Component class

TsgcHTMLComponent_ChatBox

Renders

Bootstrap 5 card + scoped CSS

Family

Chat & AI

Languages

Delphi, C++ Builder, .NET

Create it, add messages, render it

Set the Title and Height, push a few messages with AddMessage (choosing caLeft or caRight), then read HTML (or drop it into a TsgcHTMLTemplate_Bootstrap page).

uses
  sgcHTML_Enums, sgcHTML_Component_ChatBox;

var
  oChat: TsgcHTMLComponent_ChatBox;
begin
  oChat := TsgcHTMLComponent_ChatBox.Create(nil);
  try
    oChat.Title := 'Support';
    oChat.Height := '400px';
    oChat.ShowInput := True;
    oChat.InputPlaceholder := 'Type a message...';
    oChat.ShowTypingIndicator := True;

    oChat.AddMessage('Alice', 'Hi, how can I help?', caLeft, hcSecondary);
    oChat.AddMessage('You', 'My order has not arrived.', caRight, hcPrimary);

    WebModule.Response := oChat.HTML;   // Bootstrap card + chat bubbles
  finally
    oChat.Free;
  end;
end;

// Append a single new bubble (e.g. over a WebSocket push):
oChat.AddMessage('Alice', 'Let me check that for you.', caLeft);
WebSocket.WriteData(oChat.GetLastMessageHTML);
// includes: sgcHTML_Enums.hpp, sgcHTML_Component_ChatBox.hpp

TsgcHTMLComponent_ChatBox *oChat = new TsgcHTMLComponent_ChatBox(NULL);
try
{
  oChat->Title = "Support";
  oChat->Height = "400px";
  oChat->ShowInput = true;
  oChat->InputPlaceholder = "Type a message...";
  oChat->ShowTypingIndicator = true;

  oChat->AddMessage("Alice", "Hi, how can I help?", caLeft, hcSecondary);
  oChat->AddMessage("You", "My order has not arrived.", caRight, hcPrimary);

  String html = oChat->HTML;   // Bootstrap card + chat bubbles
}
__finally
{
  delete oChat;
}
using esegece.sgcWebSockets;

var chat = new TsgcHTMLComponent_ChatBox();
chat.Title = "Support";
chat.Height = "400px";
chat.ShowInput = true;
chat.InputPlaceholder = "Type a message...";
chat.ShowTypingIndicator = true;

chat.AddMessage("Alice", "Hi, how can I help?", TsgcHTMLChatAlign.caLeft, TsgcHTMLColor.hcSecondary);
chat.AddMessage("You", "My order has not arrived.", TsgcHTMLChatAlign.caRight, TsgcHTMLColor.hcPrimary);

string html = chat.HTML;   // Bootstrap card + chat bubbles

Key properties & methods

The members you reach for most often.

Messages

Messages is a TsgcHTMLChatMessages collection; each TsgcHTMLChatMessage carries Sender, Text, Timestamp, Align (caLeft/caRight), Color and AvatarInitials.

Add a message

AddMessage(aSender, aText, aAlign, aColor, aTimestamp) appends a bubble; the avatar initials and time are filled in for you when omitted.

Input bar

ShowInput toggles the form; InputPlaceholder, SendButtonText and SendButtonStyle (a TsgcHTMLButtonStyle) control the composer.

Header & typing

Title sets the card header; ShowTypingIndicator reveals the animated dots and TypingText sets its label.

Identity & size

ChatID names the element ids; Height bounds the scroll area (auto-scrolls to the newest message).

Output

HTML returns the whole card; GetLastMessageHTML returns only the most recent bubble — ideal for pushing a single update over a WebSocket.

Keep exploring

Online HelpFull API reference and usage guide for this component.
All sgcHTML ComponentsBrowse the full feature matrix of 80+ components.
Download Free TrialThe 30-day trial ships the 60.HTML demo projects.
PricingSingle, Team and Site licenses with full source code.
Best value: All-AccessEvery eSeGeCe product, Premium Support included, from €1,059/year.
See All-Access pricing

Ready to Get Started?

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