Text-based user interface

Also known as: TUI

On this page 7

A text-based user interface (TUI) is an interactive interface that presents menus, forms, panels and status information using only characters drawn on a terminal grid, and that responds to keyboard input, and often mouse input, without a graphical windowing system. Among the software fundamentals, the TUI occupies the middle ground between the line-oriented command-line interface and the pixel-based graphical user interface.

Classic examples include text editors such as Vim and Nano, system monitors such as htop, file managers such as Midnight Commander and many installers, firmware setup screens and server administration tools. In software engineering practice, a TUI is chosen when a program must stay usable over SSH, on minimal systems and with low bandwidth, while still offering more structure than a plain prompt.

How a text-based user interface draws the screen

A TUI works by treating the terminal as a fixed grid of character cells, typically 80 columns by 24 rows or larger, and redrawing parts of that grid in response to events. Each cell holds one character plus attributes such as foreground color, background color, bold and underline. The program never addresses pixels; it addresses rows and columns.

To move the cursor, change colors or clear regions, the program writes control sequences to the terminal, most commonly the ANSI escape sequences standardized in ECMA-48. Because terminals differ in which sequences they support, libraries consult a capability database such as terminfo to translate abstract operations into the correct bytes for the current terminal type.

Efficient TUIs keep an in-memory model of the screen and compute the difference between the old and new frames before writing anything. The curses family of libraries pioneered this screen-diffing technique, which matters greatly on slow serial lines and remote connections where every byte has a cost. Input arrives in raw or cbreak mode, so the program receives individual keystrokes immediately instead of waiting for the Enter key.

The following table summarizes the layers that sit between a TUI program and what the user sees.

LayerRoleTypical examples
Application logicHolds state and decides what to displayEditor buffer, process list, menu tree
TUI library or frameworkWidgets, layout, screen diffing, event loopncurses, Textual, Ratatui, Bubble Tea
Capability databaseMaps operations to terminal-specific sequencesterminfo, termcap
Terminal emulatorInterprets sequences and renders glyphsxterm, Windows Terminal, GNOME Terminal
TransportCarries bytes between program and terminalLocal pseudoterminal, SSH, serial console
Layers in a typical TUI stack

Common TUI components and interaction patterns

Most TUIs assemble a small set of reusable widgets that mimic graphical controls with characters. Box-drawing characters form borders, inverted colors mark the current selection and function keys or single-letter shortcuts trigger commands. Many applications show a persistent key legend on the bottom row so that users can discover commands without reading a manual.

  • Menus and menu bars for navigating hierarchical commands, as in BIOS and UEFI setup utilities.
  • Panels and split views that show several data sources at once, as in dual-pane file managers.
  • Forms and dialog boxes with text fields, checkboxes and buttons, common in installers.
  • Scrollable lists and tables for processes, log lines or packages.
  • Status lines and progress bars that report state without interrupting the workflow.

Modern terminals also report mouse clicks and scroll events through dedicated escape sequences, so many current TUIs accept both keyboard and mouse input. Keyboard operation nevertheless remains the primary interaction model, because it is reliable across every terminal and connection.

TUI compared with CLI and GUI

The TUI differs from the command-line interface in spatial layout and persistent state, and from the graphical user interface in its rendering medium. A CLI reads one command and prints output line by line, which makes it ideal for scripting. A GUI draws arbitrary pixels through a windowing system. The TUI redraws a full screen of text and keeps the user inside an interactive session.

The comparison below shows where each interface style fits.

PropertyCommand-line interfaceText-based user interfaceGraphical user interface
Output modelSequential lines of textFull-screen character gridPixels in windows
InteractionTyped commands and argumentsKeys, menus, optional mousePointer, touch, keyboard
ScriptabilityExcellentPoor without a separate CLI modeUsually poor
Remote use over SSHNativeNativeNeeds forwarding or remote desktop
DiscoverabilityLow, relies on help textMedium, menus and key legendsHigh, visible controls
Resource useMinimalVery lowModerate to high
Interface styles side by side

Many tools deliberately offer both a TUI and a CLI: the TUI supports interactive exploration, while the CLI flags support automation. Git front ends, package managers and container dashboards commonly follow this dual-interface pattern.

When to choose a TUI and how to build one

A TUI is the right choice when users work inside terminals as their main environment and need continuous, structured feedback. It is a weaker choice when the audience expects visual richness or when the primary workload is unattended automation. The decision table below captures typical situations.

SituationRecommended interfaceReason
Monitoring servers over SSHTUILive updates without a display server
Batch jobs in CI pipelinesCLIPredictable, scriptable, no screen control
Installer for minimal or headless systemsTUIGuided forms with few dependencies
Consumer desktop applicationGUIFamiliar controls and rich media
Developer tool used both waysTUI plus CLI flagsInteractive use and automation
Choosing an interface for a new tool

Developers rarely write escape sequences by hand. They use established TUI libraries: ncurses in C, Textual and urwid in Python, Ratatui in Rust and Bubble Tea in Go. These libraries handle terminal resizing, input decoding and color negotiation, which are the most error-prone parts of terminal programming.

Limitations and common pitfalls of TUIs

The character grid imposes hard limits on visual expression. Charts, images and proportional typography are approximated with block characters or unavailable altogether, and accessibility is uneven because screen readers interpret full-screen redraws poorly. Terminal differences add further friction, as the following table shows.

SymptomLikely causeFix
Garbled borders or stray symbolsWrong TERM value or missing Unicode fontSet the correct terminal type and a UTF-8 locale
Layout breaks after window resizeProgram ignores the SIGWINCH signalHandle resize events and redraw
Colors look wrong or washed outAssuming 24-bit color on a 256-color terminalDetect capabilities and degrade gracefully
Terminal left in a broken stateCrash before restoring normal modeRestore terminal settings in every exit path
Output cannot be piped or loggedScreen control mixed with data outputProvide a separate non-interactive mode
Frequent TUI problems and their fixes

A frequent design mistake is to build only a TUI for functions that need automation. Because a TUI expects a human at an interactive terminal, it cannot be called reliably from scripts, so mature tools expose the same operations through non-interactive commands or an API.

The simple explanation

A text-based user interface is a program screen built entirely from letters, numbers and symbols inside a terminal window. Instead of icons and pictures, it uses text boxes, highlighted menus and lines drawn with characters. You move around with the arrow keys, Tab and a few shortcut keys.

Think of it as the difference between a printed list and a control board. A command line is like sending one note at a time and getting a note back. A TUI is a whole board you can look at and operate, still made only of text. The key point: it gives structure and live feedback while staying light and remote-friendly.

How it is used in practice

A systems administrator responsible for twenty Linux servers receives an alert that one machine is responding slowly. The server has no graphical desktop, so the administrator connects over SSH from a laptop on a hotel network with a weak connection.

Within seconds, the administrator opens htop, a TUI process monitor, which shows CPU cores as bar meters, memory use and a sortable process table that refreshes every two seconds. Sorting by memory reveals a backup job consuming most of the RAM. With two keystrokes, the administrator selects the process and sends it a termination signal, then uses a TUI disk-usage tool to find the oversized log directory that triggered the problem.

The entire session used only a few kilobytes per second of bandwidth, required no remote desktop software and was completed in under ten minutes. The outcome shows why TUIs remain standard equipment in server administration.