Accordion

TsgcHTMLComponent_Accordion — render a vertically collapsing accordion of stacked, expandable panels, in Delphi, C++ Builder and .NET.

TsgcHTMLComponent_Accordion

A stack of collapsible panels built on the Bootstrap accordion. Add items with a title and content, mark which start open, then read the HTML property.

Component class

TsgcHTMLComponent_Accordion

Renders

Bootstrap 5 accordion markup

Languages

Delphi, C++ Builder, .NET

Create it, add panels, render it

Add each panel through Items.Add, set its Title, Content and Expanded flag, then read HTML.

uses
  sgcHTML_Component_Accordion;

var
  oAcc: TsgcHTMLComponent_Accordion;
begin
  oAcc := TsgcHTMLComponent_Accordion.Create(nil);
  try
    oAcc.AccordionID := 'faq';
    oAcc.Flush := False;
    oAcc.AlwaysOpen := False;

    with oAcc.Items.Add do
    begin
      Title := 'What is sgcHTML?';
      Content := 'A server-side HTML component library.';
      Expanded := True;
    end;
    with oAcc.Items.Add do
    begin
      Title := 'Which languages?';
      Content := 'Delphi, C++ Builder and .NET.';
    end;

    WebModule.Response := oAcc.HTML;   // Bootstrap accordion
  finally
    oAcc.Free;
  end;
end;
// includes: sgcHTML_Component_Accordion.hpp

TsgcHTMLComponent_Accordion *oAcc = new TsgcHTMLComponent_Accordion(NULL);
try
{
  oAcc->AccordionID = "faq";
  oAcc->Flush = false;
  oAcc->AlwaysOpen = false;

  TsgcHTMLAccordionItem *oItem = oAcc->Items->Add();
  oItem->Title = "What is sgcHTML?";
  oItem->Content = "A server-side HTML component library.";
  oItem->Expanded = true;

  oItem = oAcc->Items->Add();
  oItem->Title = "Which languages?";
  oItem->Content = "Delphi, C++ Builder and .NET.";

  String html = oAcc->HTML;   // Bootstrap accordion
}
__finally
{
  delete oAcc;
}
using esegece.sgcWebSockets;

var acc = new TsgcHTMLComponent_Accordion();
acc.AccordionID = "faq";
acc.Flush = false;
acc.AlwaysOpen = false;

var item = acc.Items.Add();
item.Title = "What is sgcHTML?";
item.Content = "A server-side HTML component library.";
item.Expanded = true;

item = acc.Items.Add();
item.Title = "Which languages?";
item.Content = "Delphi, C++ Builder and .NET.";

string html = acc.HTML;   // Bootstrap accordion

Key properties & methods

The members you reach for most often.

Items

Items (TsgcHTMLAccordionItems) holds the panels; call Items.Add to append one and configure it.

Item content

Each item exposes Title for the header button, Content for the panel body and Expanded to start it open.

Single vs multi

AlwaysOpen lets several panels stay open at once; with it off, opening one panel collapses the others.

Style

Flush removes the outer borders and rounded corners for an edge-to-edge accordion.

Identity

AccordionID sets the container id used to wire the collapse parent for the panels.

Output

HTML returns the full accordion markup — serve it, or assign it to a page template's body content.

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.