Skip to content

Rounded Corners and StyleDrawType Demo

Overview

This demo showcases the StyleDrawType property and rounded corner options available across all StyledComponents, demonstrating how to create buttons, toolbars, button groups, and category buttons with different shapes and corner radius values.

Rounded Corners Demo

What You'll Learn

  • Different StyleDrawType values (Rounded, RoundRect, Rect, Ellipse)
  • How to set corner radius
  • Applying styles to toolbars
  • Applying styles to button groups
  • Applying styles to category buttons
  • FAB (Floating Action Button) circular buttons
  • Icon-only buttons

StyleDrawType Values

btRounded (Fully Rounded)

Perfect circles or pill shapes:

pascal
Button.StyleDrawType := btRounded;
  • Square buttons: Becomes circular
  • Rectangular buttons: Becomes pill-shaped
  • Use case: FAB buttons, modern UI, icon buttons

btRoundRect (Rounded Corners)

Rectangles with rounded corners:

pascal
Button.StyleDrawType := btRoundRect;
Button.StyleRadius := 8;  // Corner radius in pixels
  • Adjustable radius: Use StyleRadius property
  • Default radius: 6 pixels
  • Use case: Modern cards, soft UI elements

btRect (Rectangle)

Perfect rectangles with sharp corners:

pascal
Button.StyleDrawType := btRect;
  • No rounding: Sharp 90° corners
  • Use case: Classic interfaces, strict grids

btEllipse (Circle)

Perfect circles regardless of dimensions:

pascal
Button.StyleDrawType := btEllipse;
  • Forces circular shape: Ignores width/height ratio
  • Use case: FAB buttons, icon buttons, badges

Corner Radius (StyleRadius)

For btRoundRect type, control the corner radius:

pascal
Button.StyleDrawType := btRoundRect;
Button.StyleRadius := 4;   // Subtle rounding
Button.StyleRadius := 8;   // Medium rounding
Button.StyleRadius := 16;  // Heavy rounding
Button.StyleRadius := 32;  // Very rounded

Large radius values approach btRounded appearance.

Demo Layout

The demo displays styled components in a grid:

Top Section: Regular Buttons (TStyledButton)

Four buttons showing different families:

  • Angular: Material Design button
  • Bootstrap: Web-style button
  • Colored: Color-based button
  • Classic: Windows-style button

Middle Section: Graphic Buttons (TStyledGraphicButton)

Same four buttons in graphic (non-windowed) variant.

FAB Section: Floating Action Buttons

Circular icon buttons (Material Design):

  • Home icon
  • Bookmark icon
  • Trash icon
  • Heart icon (disabled)

Icon Buttons Section

Square icon-only buttons:

  • Various icons
  • No captions
  • Compact layout

Bottom Section: Containers

  • TStyledToolbar: Toolbar with styled buttons
  • TStyledButtonGroup: Button group
  • TStyledCategoryButtons: Categorized buttons

Interactive Controls

The demo includes controls to modify appearance:

ControlFunction
Width TrackbarAdjust button/container width
Height TrackbarAdjust button/container height
Show CaptionToggle caption visibility
Show IconToggle icon visibility
Caption AlignmentLeft, Center, Right
Image AlignmentLeft, Right, Top, Bottom, Center

Changes apply to all components simultaneously.

FAB (Floating Action Buttons)

Material Design circular action buttons:

pascal
FABButton := TStyledButton.CreateStyled(Self,
  ANGULAR_LIGHT_FAMILY,
  btn_PrimaryDeepPurple,
  FlatAttr);
FABButton.StyleDrawType := btEllipse;  // Force circular
FABButton.Width := 56;   // Material Design standard size
FABButton.Height := 56;
FABButton.Images := ImageList;
FABButton.ImageIndex := 0;
FABButton.ImageAlignment := iaCenter;  // Center icon
FABButton.ShowCaption := False;  // No caption

FAB Sizes

Material Design defines standard FAB sizes:

  • Default FAB: 56x56 pixels
  • Mini FAB: 40x40 pixels
  • Extended FAB: 48+ height, variable width (with caption)

Icon Buttons

Square buttons with only icons:

pascal
IconButton := TStyledButton.CreateStyled(Self,
  ANGULAR_LIGHT_FAMILY,
  btn_PrimaryDeepPurple,
  BasicAttr);
IconButton.StyleDrawType := btRoundRect;
IconButton.StyleRadius := 4;
IconButton.Width := 40;
IconButton.Height := 40;
IconButton.Images := ImageList;
IconButton.ImageIndex := 1;
IconButton.ImageAlignment := iaCenter;
IconButton.ShowCaption := False;

Applying to Toolbars

Set default style for all toolbar buttons:

pascal
// At design-time or globally
TStyledToolbar.RegisterDefaultRenderingStyle(btRounded);

// At runtime for specific toolbar
Toolbar.StyleDrawType := btRounded;

Individual toolbar buttons can override:

pascal
ToolButton.StyleDrawType := btRoundRect;
ToolButton.StyleRadius := 6;

Applying to Button Groups

Set style for button group items:

pascal
ButtonGroup.StyleDrawType := btRounded;

// Individual items can override
ButtonGroup.Items[0].StyleDrawType := btRoundRect;

Applying to Category Buttons

Set style for category button items:

pascal
CategoryButtons.StyleDrawType := btRounded;

// Items inherit from parent
// Or set per category/item

Global Default Registration

Set application-wide defaults:

pascal
// In project source or main form OnCreate
TStyledButton.RegisterDefaultRenderingStyle(btRounded);
TStyledToolbar.RegisterDefaultRenderingStyle(btRounded);
TStyledButtonGroup.RegisterDefaultRenderingStyle(btRounded);
TStyledCategoryButtons.RegisterDefaultRenderingStyle(btRounded);

All new components will use these defaults.

Combining with Style Families

StyleDrawType works with all families:

pascal
// Bootstrap rounded
Button.StyleFamily := BOOTSTRAP_FAMILY;
Button.StyleClass := btn_primary;
Button.StyleDrawType := btRounded;

// Angular Material with RoundRect
Button.StyleFamily := ANGULAR_LIGHT_FAMILY;
Button.StyleClass := btn_PrimaryDeepPurple;
Button.StyleDrawType := btRoundRect;
Button.StyleRadius := 4;  // Material Design uses 4px

// Classic with sharp corners
Button.StyleFamily := DEFAULT_CLASSIC_FAMILY;
Button.StyleDrawType := btRect;

Responsive Sizing

The demo demonstrates how components resize:

  • Width trackbar: Changes button/container width
  • Height trackbar: Changes button/container height
  • DPI-aware: Automatic scaling on high-DPI displays

All shapes maintain proper proportions when resized.

Caption and Image Positioning

Combine StyleDrawType with alignment:

pascal
// Pill-shaped button with left icon
Button.StyleDrawType := btRounded;
Button.ImageAlignment := iaLeft;
Button.Caption := 'Save';

// Circular icon button
Button.StyleDrawType := btEllipse;
Button.ImageAlignment := iaCenter;
Button.ShowCaption := False;

// Rounded card with top image
Button.StyleDrawType := btRoundRect;
Button.StyleRadius := 12;
Button.ImageAlignment := iaTop;
Button.Caption := 'Card Title';

Technical Details

Source Location

Demos/source/RoundedCornersForm.pas

Supported Versions

All Delphi versions (XE6+)

Key Properties

PropertyTypeDescription
StyleDrawTypeTStyledButtonDrawTypeButton/container shape
StyleRadiusIntegerCorner radius for btRoundRect
ImageAlignmentTImageAlignmentIcon position
ShowCaptionBooleanDisplay caption

StyleDrawType Enum

pascal
type
  TStyledButtonDrawType = (
    btRounded,    // Fully rounded (circle/pill)
    btRoundRect,  // Rounded rectangle
    btRect,       // Sharp rectangle
    btEllipse     // Force circle
  );

Best Practices

1. Consistency

Use the same StyleDrawType for related components:

pascal
// All buttons rounded
Button1.StyleDrawType := btRounded;
Button2.StyleDrawType := btRounded;
Button3.StyleDrawType := btRounded;

2. Context-Appropriate Shapes

  • btRect: Traditional desktop apps
  • btRoundRect: Modern desktop apps, cards
  • btRounded: Modern mobile-like UI
  • btEllipse: FAB buttons, avatar buttons

3. Radius Values

Common radius values:

  • 2-4px: Subtle, professional
  • 6-8px: Balanced, modern
  • 12-16px: Prominent, friendly
  • 20+px: Very soft, approaching btRounded

4. Icon Buttons

For icon-only buttons:

pascal
Button.ShowCaption := False;
Button.ImageAlignment := iaCenter;
Button.Width := Button.Height;  // Square or circular

Platform Considerations

Windows

All StyleDrawType values render correctly.

High DPI

  • Corner radius scales with DPI
  • Icons scale automatically (with ImageList)
  • Proportions maintained

VCL Styles

StyledComponents render independently of VCL Styles, so StyleDrawType always works.

See Also

Released under Apache License, Version 2.0.