Introduction
FTXUI is a header-friendly C++ library for creating rich terminal user interfaces. It uses a functional, declarative approach inspired by modern UI frameworks, making TUI development in C++ feel as natural as building web layouts.
What FTXUI Does
- Provides a declarative DOM-like API for composing terminal UI elements
- Supports interactive components like buttons, inputs, menus, and toggles
- Implements flexbox-style layout with hbox, vbox, and flex for responsive design
- Renders smooth animations and transitions in the terminal
- Compiles to WebAssembly for running TUI apps in the browser
Architecture Overview
FTXUI is organized into three modules: dom (layout and rendering), component (interactive widgets), and screen (terminal output). The dom layer builds a virtual element tree that is diffed and rendered efficiently. Components handle input events through a simple event loop. The library uses only the C++ standard library with no external dependencies.
Self-Hosting & Configuration
- Add as a CMake dependency via FetchContent or install system-wide
- Header-only option available for simpler integration
- Works on Linux, macOS, Windows (MSVC, GCC, Clang)
- WebAssembly builds supported via Emscripten for browser deployment
- No runtime configuration files needed; everything is set in code
Key Features
- Zero external dependencies beyond the C++ standard library
- Functional composition model for building complex layouts from simple elements
- Built-in color support including true color (24-bit) terminals
- Canvas element for drawing graphics, charts, and plots in the terminal
- Thread-safe screen updates for concurrent applications
Comparison with Similar Tools
- ncurses — C API with manual memory management; FTXUI is modern C++ with RAII and composition
- Textual (Python) — Python-based TUI framework; FTXUI targets native C++ performance
- Ratatui (Rust) — Rust TUI library; FTXUI fills the same niche for C++ developers
- Dear ImGui — immediate mode GUI for graphics; FTXUI is terminal-only and declarative
- Terminal.Gui (.NET) — .NET TUI framework; FTXUI serves the C++ ecosystem
FAQ
Q: Does FTXUI support mouse input? A: Yes. It handles mouse clicks, scroll events, and hover detection on supported terminals.
Q: Can I run FTXUI apps in the browser? A: Yes. FTXUI compiles to WebAssembly via Emscripten, with a DOM-based rendering backend.
Q: Is it header-only? A: It can be used as a compiled library or fetched via CMake FetchContent. It is not strictly header-only but integrates easily.
Q: What terminals are supported? A: Any terminal supporting ANSI escape codes, including xterm, iTerm2, Windows Terminal, and Alacritty.