Skip to content

TStyledButtonGroup - Technical Reference

Overview

TStyledButtonGroup extends TButtonGroup with styled button rendering and additional layout options for button items.

Class Hierarchy

TWinControl
  └─ TButtonGroup
      └─ TStyledButtonGroup

Unit

pascal
Vcl.StyledButtonGroup

Description

TStyledButtonGroup maintains full compatibility with TButtonGroup while adding modern styling capabilities, image positioning options, caption alignment, and per-item style customization.

Key Features

  • Full TButtonGroup compatibility: All standard properties and events
  • Styled button items: StyleFamily/Class/Appearance for each item
  • Flexible image positioning: Left, Right, Top, Bottom, Center
  • Caption alignment: Left, Center, Right
  • Flat appearance option: Modern flat button style
  • Per-item styling: Each button can have custom style
  • Notification badges: Badge support for button items

Main Properties

Layout Properties

PropertyTypeDescription
ButtonOptionsTGroupButtonOptionsLayout mode (gboFullSize, gboGroupStyle, gboShowCaptions)
ButtonWidthIntegerWidth of buttons in gboGroupStyle mode
ButtonHeightIntegerHeight of buttons
ImagePositionTStyledImagePositionImage position (sipImageLeft, sipImageRight, sipImageTop, sipImageBottom, sipCenter)
CaptionAlignmentTStyledCaptionAlignmentCaption alignment (scaLeft, scaCenter, scaRight)
FlatBooleanFlat button appearance

Styling Properties

PropertyTypeDescription
StyleFamilyTStyledButtonFamilyDefault style family for all items
StyleClassTStyledButtonClassDefault style class for all items
StyleAppearanceTStyledButtonAppearanceDefault appearance for all items
StyleDrawTypeTStyledButtonDrawTypeButton shape
StyleRadiusIntegerCorner radius

Button Items

PropertyTypeDescription
ItemsTGroupButtonItemsCollection of button items
ItemIndexIntegerCurrently selected item index
ImagesTCustomImageListImageList for button icons

TGroupButtonItem Properties

Each button item can have:

PropertyTypeDescription
CaptionStringButton caption
ImageIndexTImageIndexImage index from ImageList
HintStringHint text
EnabledBooleanEnable/disable item
StyleFamilyTStyledButtonFamilyOverride group's style family
StyleClassTStyledButtonClassOverride group's style class
StyleAppearanceTStyledButtonAppearanceOverride group's appearance
NotificationBadgeTNotificationBadgeAttributesBadge configuration

Usage Examples

Basic ButtonGroup

pascal
var
  Group: TStyledButtonGroup;
  Item: TGroupButtonItem;
begin
  Group := TStyledButtonGroup.CreateStyled(Self,
    BOOTSTRAP_FAMILY,
    btn_primary,
    BOOTSTRAP_NORMAL);
  Group.Parent := Self;
  Group.Align := alLeft;
  Group.Images := ImageList1;

  Item := Group.Items.Add;
  Item.Caption := 'Home';
  Item.ImageIndex := 0;
end;

ButtonGroup with Image Positioning

pascal
Group := TStyledButtonGroup.CreateStyled(Self,
  ANGULAR_LIGHT_FAMILY,
  acl_primary,
  ANGULAR_RAISED);
Group.Parent := Self;
Group.ImagePosition := sipImageTop;  // Image above caption
Group.CaptionAlignment := scaCenter;
Group.ButtonHeight := 80;

Per-Item Custom Styling

pascal
Group := TStyledButtonGroup.CreateStyled(Self,
  BOOTSTRAP_FAMILY,
  btn_secondary,
  BOOTSTRAP_NORMAL);

// Override specific items
Group.Items[0].StyleClass := btn_primary;  // Blue
Group.Items[1].StyleClass := btn_success;  // Green
Group.Items[2].StyleClass := btn_danger;   // Red

Flat ButtonGroup

pascal
Group := TStyledButtonGroup.CreateStyled(Self,
  BOOTSTRAP_FAMILY,
  btn_secondary,
  BOOTSTRAP_NORMAL);
Group.Flat := True;
Group.CaptionAlignment := scaLeft;
Group.ImagePosition := sipImageLeft;

See Also

Released under Apache License, Version 2.0.