Hex.pm Docs License

A direct-mode Terminal UI framework for Elixir/BEAM, inspired by BubbleTea (Go) and Ratatui (Rust).

TermUI leverages BEAM's unique strengths—fault tolerance, actor model, hot code reloading—to build robust terminal applications using The Elm Architecture.

Blue Theme    Yellow Theme

Features

  • Elm Architecture - Predictable state management with init/update/view
  • Rich Widget Library - Gauges, tables, menus, charts, dialogs, and more
  • Efficient Rendering - Double-buffered differential updates at 60 FPS
  • Themable - True color RGB support (16 million colors)
  • Cross-Platform - Linux, macOS, Windows 10+ terminal support
  • OTP Integration - Supervision trees, fault tolerance, hot code reload

Widgets

WidgetDescription
GaugeProgress bar with color zones
SparklineCompact inline trend graph
TableScrollable data table with selection and sorting
MenuHierarchical menu with submenus
TextInputSingle-line and multi-line text input
DialogModal dialog with buttons
PickListModal selection with type-ahead filtering
TabsTabbed interface for switchable panels
AlertDialogModal dialog for confirmations with standard button configurations
ContextMenuRight-click context menu with keyboard and mouse support
ToastAuto-dismissing notifications with stacking
ViewportScrollable view with keyboard and mouse support
SplitPaneResizable multi-pane layouts for IDE-style interfaces
TreeViewHierarchical data display with expand/collapse
FormBuilderStructured forms with validation and multiple field types
CommandPaletteVS Code-style command discovery with fuzzy search
BarChartHorizontal/vertical bar charts for categorical data
LineChartLine charts using Braille characters for sub-character resolution
CanvasDirect drawing surface for custom visualizations
LogViewerHigh-performance log viewer with virtual scrolling and filtering
StreamWidgetGenStage-integrated widget with backpressure support
ProcessMonitorLive BEAM process inspection with sorting and filtering
SupervisionTreeViewerOTP supervision hierarchy visualization
ClusterDashboardDistributed Erlang cluster monitoring

Installation

Add term_ui to your dependencies in mix.exs:

def deps do
  [
    {:term_ui, "~> 0.2.0"}
  ]
end

Quick Start

defmodule Counter do
  use TermUI.Elm

  alias TermUI.Event
  alias TermUI.Renderer.Style

  def init(_opts), do: %{count: 0}

  def event_to_msg(%Event.Key{key: :up}, _state), do: {:msg, :increment}
  def event_to_msg(%Event.Key{key: :down}, _state), do: {:msg, :decrement}
  def event_to_msg(%Event.Key{key: "q"}, _state), do: {:msg, :quit}
  def event_to_msg(_, _), do: :ignore

  def update(:increment, state), do: {%{state | count: state.count + 1}, []}
  def update(:decrement, state), do: {%{state | count: state.count - 1}, []}
  def update(:quit, state), do: {state, [:quit]}

  def view(state) do
    stack(:vertical, [
      text("Counter Example", Style.new(fg: :cyan, attrs: [:bold])),
      text("", nil),
      text("Count: #{state.count}", nil),
      text("", nil),
      text("↑/↓ to change, Q to quit", Style.new(fg: :bright_black))
    ])
  end
end

# Run the application
TermUI.Runtime.run(root: Counter)

Documentation

User Guides

GuideDescription
OverviewIntroduction to TermUI concepts
Getting StartedFirst steps and setup
Elm ArchitectureUnderstanding init/update/view
EventsHandling keyboard and mouse input
StylingColors, attributes, and themes
LayoutArranging components on screen
WidgetsUsing built-in widgets
TerminalTerminal capabilities and modes
CommandsSide effects and async operations
Advanced WidgetsNavigation, visualization, streaming, and BEAM introspection widgets

Developer Guides

GuideDescription
Architecture OverviewSystem layers and design
Runtime InternalsGenServer event loop and state
Rendering PipelineView to terminal output stages
Event SystemInput parsing and dispatch
Buffer ManagementETS double buffering
Terminal LayerRaw mode and ANSI sequences
Elm ImplementationElm Architecture for OTP
Creating WidgetsHow to build and contribute widgets
Testing FrameworkComponent and widget testing

Examples

The examples/ directory contains standalone applications demonstrating each widget:

ExampleDescription
alert_dialogConfirmation dialogs with standard buttons
bar_chartHorizontal and vertical bar charts
canvasFree-form drawing with box/braille characters
cluster_dashboardDistributed Erlang cluster monitoring
command_paletteVS Code-style command discovery
context_menuRight-click context menus
dashboardSystem monitoring dashboard with multiple widgets
dialogModal dialogs with buttons
form_builderStructured forms with validation
gaugeProgress bars and percentage indicators
line_chartBraille-based line charts
log_viewerReal-time log display with filtering
menuNested menus with keyboard navigation
pick_listModal selection with type-ahead
process_monitorLive BEAM process inspection
sparklineInline data visualization
split_paneResizable multi-pane layouts
stream_widgetBackpressure-aware data streaming
supervision_tree_viewerOTP supervision hierarchy
tableScrollable data tables with selection
tabsTab-based navigation
text_inputSingle and multi-line text input
toastAuto-dismissing notifications
tree_viewHierarchical data with expand/collapse
viewportScrollable content areas
# Run any example
cd examples/dashboard
mix deps.get
mix run run.exs

Requirements

  • Elixir 1.15+
  • OTP 28+ (required for native raw terminal mode)
  • Terminal with Unicode support

License

MIT License - see LICENSE for details.