TermUI User Guides

View Source

Welcome to the TermUI documentation. These guides cover everything you need to build terminal user interfaces with Elixir.

Guides

  1. Overview - Introduction to TermUI and its architecture
  2. Getting Started - Build your first TermUI application
  3. The Elm Architecture - Understanding the component model
  4. Events - Handling keyboard, mouse, and other input
  5. Styling - Colors, attributes, and themes
  6. Layout - Positioning and sizing components
  7. Widgets - Using pre-built components
  8. Terminal - Terminal modes and capabilities
  9. Commands - Side effects and async operations
  10. Advanced Widgets - Navigation, visualization, data streaming, and BEAM introspection widgets

Quick Start

defmodule MyApp do
  use TermUI.Elm

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

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

  def update(:inc, s), do: {%{s | count: s.count + 1}, []}
  def update(:dec, s), do: {%{s | count: s.count - 1}, []}
  def update(:quit, s), do: {s, [:quit]}

  def view(state), do: text("Count: #{state.count}")
end

# Run with: TermUI.Runtime.run(root: MyApp)

Requirements

  • Elixir 1.15+
  • OTP 28+
  • Terminal with ANSI support

Examples

See the examples/ directory for complete applications:

  • dashboard - System monitoring dashboard with gauges, sparklines, and tables