Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Catalog · How the catalog works
Anything · Lazarus or Delphi
Random projectRandom project

lazfluid

A lightweight desktop REST API client and Fluent UI Component library for Lazarus

View on GitHub

Member rating

No ratings yet.

Sign in to rate this project.

README

LazFluid — Fluent 2 UI Components for Lazarus/LCL

A Free Pascal / Lazarus component library implementing Fluent 2 (Microsoft's Fluent UI v9) styled controls with Light/Dark theme support, anti-aliased rendering via BGRABitmap, and hover animations.

Components

Component Unit Description
TFluentButton FluentButton Button with Primary, Secondary, Subtle, Outline, Transparent appearances, Small/Medium/Large sizes, and modal dialog roles
TFluentTextBox FluentTextBox Text input with placeholder text, animated focus border, and internal TEdit for IME/clipboard support
TFluentCheckBox FluentCheckBox Checkbox with checked, unchecked, and indeterminate states
TFluentRadioButton FluentRadioButton Radio button with Fluent 2 styling
TFluentDropDown FluentDropDown Dropdown selector with popup list, scroll support, and auto-close on outside click
TFluentScrollBar FluentScrollBar Themed scrollbar for embedding in custom controls
TFluentProgressBar FluentProgressBar Progress bar with determinate and indeterminate (animated blob) modes
TFluentListBox FluentListBox Selectable list with single/multi-select, hover highlight, optional border, and scrollbar
TFluentTabBar FluentTabBar Tab bar with Underline and Contained styles, close/add buttons, overflow scrolling, and optional drag reordering
TFluentMenuBar FluentMenu Menu bar with popup menus, Alt+letter hotkey activation, arrow-key navigation, and compound bottom borders
TFluentPopupMenu FluentMenu Standalone popup menu component
TFluentStatusBar FluentStatusBar Status bar with themed panels
TFluentHeaderBar FluentHeaderBar Header bar with title, subtitle, search placeholder, and hamburger menu toggle
TFluentScrollPanel FluentPanel Scrollable panel with embedded scrollbar, drag-to-scroll, and child position management
TFluentTreeView FluentTreeView Tree view with optional border, expand/collapse, node badges, context menus, inline rename (F2), and right-click events
TFluentCodeEditor FluentCodeEditor Multi-line code editor with syntax highlighting (JSON, HTML, CSS, XML), line numbers, gutter, optional border, and scrollbar
TFluentKeyValueGrid FluentKeyValueGrid Key-value pair editor grid with optional border/grid lines, enable/disable checkboxes, inline editing, ghost row adds, and optional row reordering

Non-visual Components

Component Unit Description
TFluentThemeManager FluentTheme Theme manager singleton — holds mode (Light/Dark/System), accent color, design tokens
TFluentFormThemer FluentThemeAdapter Drop-on-form component that auto-themes the form and all child controls on theme change

Supporting Units

Unit Purpose
FluentTypes Shared enumerations and types
FluentTheme TFluentThemeManager singleton, TFluentTokens design-token record, light/dark palettes, accent-color derivation, listener system
FluentDrawing BGRABitmap drawing helpers (rounded rects, control surfaces, focus rings, color blending)
FluentControl TFluentBaseControl — base class with hover animation, theme registration, DPI scaling, keyboard-focus tracking
FluentHighlighter Base syntax highlighter framework
FluentJSONHL / FluentCSSHL / FluentHTMLHL / FluentXMLHL Language-specific syntax highlighters

Features

  • Theme System: Light/Dark mode with automatic Windows system detection (ftmSystem)
  • Design Tokens: Full Fluent 2 semantic token set (colors, radii, spacing, typography)
  • Anti-aliased Rendering: Uses BGRABitmap for smooth rounded corners, focus rings, and compound borders
  • Hover Animations: ~150ms linear transitions on state changes via 16ms timer
  • Live Re-theming: Change accent color or theme mode at runtime — all controls update instantly via listener system
  • DPI Scaling: Controls scale automatically for high-DPI displays
  • IDE Integration: Components appear under a "Fluent" tab in the Lazarus IDE palette
  • Keyboard Support: Focus rings, Alt+letter menu hotkeys, F2 inline rename in tree view
  • Optional Reordering: Tabs and key-value rows can be drag-reordered via opt-in properties and cancelable events

Dependencies

  • LCL (built-in with Lazarus)
  • BGRABitmap — install via Lazarus Online Package Manager (OPM)

Installation

1. Install BGRABitmap

Open Lazarus IDE → Package → Online Package Manager → Search "BGRABitmap" → Install

2. Compile Runtime Package

Open packages/lazfluid_rt.lpk in Lazarus → Click Compile (do not install — it's a runtime package)

3. Install Designtime Package

Open packages/lazfluid_dt.lpk in Lazarus → Click Use > Install → Lazarus rebuilds the IDE with the new components

4. Run the Demo

Open demo/FluentDemo.lpi → Press F9 to compile and run

CLI Build

pascal
C:\lazarus\lazbuild.exe packages/lazfluid_rt.lpk
C:\lazarus\lazbuild.exe packages/lazfluid_dt.lpk
C:\lazarus\lazbuild.exe demo/FluentDemo.lpi

Package compile order matters: lazfluid_rt must compile before lazfluid_dt.

Project Structure

pascal
lazfluid/
????????? src/                          # All control source units
???   ????????? FluentControl.pas         # Base control class
???   ????????? FluentTheme.pas           # Theme manager, tokens, palettes
???   ????????? FluentTypes.pas           # Shared enums/types
???   ????????? FluentDrawing.pas         # BGRABitmap drawing helpers
???   ????????? FluentThemeAdapter.pas    # TFluentFormThemer
???   ????????? FluentButton.pas
???   ????????? FluentTextBox.pas
???   ????????? FluentCheckBox.pas
???   ????????? FluentRadioButton.pas
???   ????????? FluentDropDown.pas
???   ????????? FluentScrollBar.pas
???   ????????? FluentProgressBar.pas
???   ????????? FluentListBox.pas
???   ????????? FluentTabBar.pas
???   ????????? FluentMenu.pas            # MenuBar + PopupMenu + MenuPopup
???   ????????? FluentStatusBar.pas
???   ????????? FluentHeaderBar.pas
???   ????????? FluentPanel.pas           # ScrollPanel
???   ????????? FluentTreeView.pas
???   ????????? FluentCodeEditor.pas
???   ????????? FluentKeyValueGrid.pas
???   ????????? FluentHighlighter.pas     # Base highlighter
???   ????????? FluentJSONHL.pas
???   ????????? FluentCSSHL.pas
???   ????????? FluentHTMLHL.pas
???   ????????? FluentXMLHL.pas
????????? packages/                     # Lazarus package descriptors
???   ????????? lazfluid_rt.lpk           # Runtime package
???   ????????? lazfluid_rt.pas
???   ????????? lazfluid_dt.lpk           # Designtime package
???   ????????? lazfluid_dt.pas
???   ????????? register_lazfluid.pas     # IDE component registration
????????? demo/                         # Demo app
???   ????????? FluentDemo.lpi
???   ????????? FluentDemo.lpr
???   ????????? MainForm.pas
???   ????????? MainForm.lfm
????????? restlab/                      # Violin RestLab (MIT-licensed demo app)
???   ????????? ViolinRestLab.lpi
???   ????????? ViolinRestLab.lpr
???   ????????? MainFormUnit.pas
???   ????????? MainFormUnit.lfm
???   ????????? RequestFrame.pas
???   ????????? RequestFrame.lfm
???   ????????? AboutForm.pas
???   ????????? AboutForm.lfm
???   ????????? RequestModel.pas
???   ????????? HttpExecutor.pas
???   ????????? CollectionIO.pas
???   ????????? OSDarkThemeManager.pas
???   ????????? LICENSE                   # MIT
???   ????????? appdesc.md
????????? LICENSE                       # LGPL-2.1+exception (library)
????????? COPYING.LGPL.txt
????????? COPYING.modifiedLGPL.txt
????????? AGENTS.md

Usage Example

pascal
uses FluentButton, FluentTheme, FluentTypes;

// Create a primary button
var Btn := TFluentButton.Create(Self);
Btn.Parent := Self;
Btn.Caption := 'Click Me';
Btn.Appearance := fbaPrimary;
Btn.Size := fbsMedium;

// Toggle theme
FluentThemeMgr.Mode := ftmDark;

// Change accent color
FluentThemeMgr.AccentColor := $107C10;

Theme API

pascal
// Access the singleton
FluentThemeMgr.Mode := ftmLight;    // ftmLight, ftmDark, ftmSystem
FluentThemeMgr.AccentColor := $0F6BD;

// Read current tokens
var BgColor := FluentThemeMgr.Tokens.ColorNeutralBackground1;

// Read the resolved theme after ftmSystem is applied
var DarkChrome := FluentThemeMgr.IsDark;
var ActualMode := FluentThemeMgr.ResolvedMode; // ftmLight or ftmDark

// Listen for changes
FluentThemeMgr.AddListener(@MyHandler);

Design Tokens

The theme system provides Fluent 2 semantic tokens:

  • Backgrounds: ColorNeutralBackground1..3, ColorSubtleBackground*
  • Foregrounds: ColorNeutralForeground1..4, ColorNeutralForegroundOnBrand
  • Strokes: ColorNeutralStroke1..2, ColorNeutralStrokeAccessible
  • Brand: ColorBrandBackground, ColorBrandBackgroundHover/Pressed, ColorBrandForeground
  • Focus: ColorStrokeFocus1 (outer), ColorStrokeFocus2 (inner)
  • Radii: RadiusSmall=2, RadiusMedium=4, RadiusLarge=8
  • Font Sizes: FontSizeCaption=12, FontSizeBody=14, FontSizeSubtitle=20

Notes

  • BGRABitmap is required for anti-aliased rendering. Without it, corners would appear jagged.
  • The controls intentionally look like Windows Fluent UI on all platforms.
  • TFluentTextBox uses an internal TEdit for text input handling (IME, clipboard, caret).
  • TFluentButton supports dialog button behavior through ModalResult, Default, and Cancel.
  • TFluentCodeEditor is a custom-painted code editor — not a wrapper around a native widget.
  • TFluentCodeEditor, TFluentListBox, TFluentTreeView, and TFluentKeyValueGrid expose ShowBorder; disabling the code editor border also suppresses its focus ring.
  • TFluentTabBar.AllowReorder enables tab drag reordering with OnTabReorder / OnTabReordered; TFluentKeyValueGrid.AllowRowReorder enables row drag reordering with OnRowReorder / OnRowReordered.
  • Animations use simple timer-based linear interpolation (~150ms). Reveal/acrylic effects are not implemented.
  • On Windows, ftmSystem mode reads HKCU\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize\AppsUseLightTheme. On other platforms it defaults to Light.
  • Popup forms (dropdown, menu) send WM_NCACTIVATE(TRUE) to the owner form on Windows so the title bar stays visually active.

License

  • LazFluid component library (src/, packages/, demo/): LGPL-2.1-or-later with linking exception — see LICENSE. The exception allows proprietary applications to use LazFluid components without being subject to the LGPL copyleft, matching the approach used by the Lazarus LCL itself.
  • Violin RestLab (restlab/): MIT — see restlab/LICENSE.

This library uses BGRABitmap, distributed under the same modified LGPL license.