Skip to main content

Overview

LibGUI is SerenityOS’s native GUI toolkit providing widgets, windows, layouts, and event handling for building graphical applications. It offers a rich set of controls from basic buttons to complex table views, all with a clean object-oriented API.
LibGUI applications automatically integrate with the SerenityOS WindowServer for window management, theming, and input handling.

Getting Started

Application

Every GUI application starts with a GUI::Application instance.
  1. Create Application: GUI::Application::create()
  2. Build UI: Create windows and widgets
  3. Show Windows: Call window->show()
  4. Run Event Loop: Call app->exec()
  5. Cleanup: Automatic when app exits

Windows

Window

Top-level window container.
Key Properties:
String
Window title displayed in title bar
bool
Whether window can be resized by user
bool
If true, blocks interaction with other windows
bool
Fullscreen mode (hides title bar and decorations)

Core Widgets

Widget

Base class for all GUI widgets.

Button

Clickable button widget.

Label

Text display widget.

TextBox & TextEditor

Single-line and multi-line text input.

CheckBox & RadioButton

Toggle controls.

ComboBox

Dropdown selection widget.

Slider & SpinBox

Numeric input controls.

Container Widgets

GroupBox

Visual grouping with optional title.

Frame

Decorative frame container.

TabWidget

Multi-page tabbed interface.

SplitterWidget

Resizable split view.

Layouts

VerticalBoxLayout & HorizontalBoxLayout

Stack widgets vertically or horizontally.

Advanced Widgets

TableView & ListView

Display tabular and list data.

TreeView

Hierarchical tree display.

Dialogs

MessageBox

Simple message dialogs.

FilePicker

File selection dialogs.

Actions & Menus

Action

Reusable command with icon, text, and shortcut.
Application menus.

Events

Event Handling

Override event handlers in custom widgets.

Best Practices

  • Use layouts instead of manual positioning
  • Set size constraints (min/max) instead of fixed sizes when possible
  • Use spacers to control widget spacing
  • Nest layouts for complex UIs
  • Use semantic colors via Gfx::ColorRole
  • Don’t hardcode colors - respect system theme
  • Use standard icons from /res/icons/
  • Follow SerenityOS HIG (Human Interface Guidelines)