Single header · C++17 · MIT licensed

Beautiful terminal UIs in modern C++

cpp-tui is a lightweight, single-header library with 50+ widgets, a flex layout engine, built-in themes, and full mouse and keyboard support — include it and start building.

#include "cpptui.hpp"

Recording of the widget_demo example: typing into text inputs, moving a slider, ticking checkboxes, then switching between the Nord, Tokyo Night and Catppuccin Mocha themes
Recorded from examples/widget_demo.cpp

Why cpp-tui

Single Header

Drop cpptui.hpp into your source directory. Zero dependencies, no extra build steps.

50+ Widgets

Form controls, editors, paginated tables, Braille charts, tree views, and modal dialogs.

Flex Layout Engine

Vertical, Horizontal, Grid, SplitPane, and auto-shrink sizing with multi-pass constraint clamping.

Dynamic Theming

Includes Catppuccin Mocha, Latte, Nord, Tokyo Night, and Solarized Light with runtime switching.

Complete Event Model

Mouse tracking, scroll wheel, focus cycling, global shortcuts with modifiers, and cross-thread updates.

Unicode & CJK Precision

Built-in cell width calculation for multi-byte UTF-8, double-width CJK ideographs, and emoji.

Quick start

A complete program — a label, a button, and q to quit:

#include "cpptui.hpp"
using namespace cpptui;

int main() {
    App app;
    Theme::set_theme(Theme::Dark());

    auto root = std::make_shared<Vertical>();
    root->add(std::make_shared<Label>("Hello, cpp-tui!"));
    root->add(std::make_shared<Button>("Click me", []() {
        // Handle button click
    }));

    app.register_exit_key('q');
    app.run(root);
    return 0;
}

See it in action

Real output from two of the 18 bundled examples: a live system monitor and a spectrum analyzer.

htop_sim: CPU meters, memory bars, CPU history and a process table
examples/htop_sim.cpp
spectrum_sim: real-time spectrum analyzer line chart with a hover tooltip
examples/spectrum_sim.cpp

See all examples →

Explore the docs