rxtui 0.1.0

A framework for building beautiful, responsive terminal user interfaces with a DOM-style hierarchical approach
Documentation

Radical TUI - Terminal User Interface Framework

A reactive terminal UI framework inspired by React's virtual DOM architecture. Provides a declarative API for building interactive terminal applications.

Architecture Overview

    ┌─────────────┐     ┌─────────────┐     ┌─────────────┐
    │  Elements   │────▶│    Node     │────▶│    VDom     │
    │   Factory   │     │    Tree     │     │   State     │
    └─────────────┘     └─────────────┘     └─────────────┘
           │                    │                    │
           │                    │                    │
           ▼                    ▼                    ▼
    ┌─────────────┐     ┌─────────────┐     ┌─────────────┐
    │    Style    │     │    Diff     │────▶│   Render    │
    │   System    │     │   Engine    │     │   Engine    │
    └─────────────┘     └─────────────┘     └─────────────┘
                                                    │
                                                    ▼
                                           ┌─────────────┐
                                           │  Terminal   │
                                           │   Output    │
                                           └─────────────┘

Quick Start

use rxtui::{Elements, ElementBuilder, Text, Node, Color, Direction, Spacing};

// Create UI elements using the Elements factory
let ui = Elements::div()
    .background(Color::Blue)
    .padding(Spacing::all(2))
    .children(vec![
        Text::new("Hello, TUI!").color(Color::White).into(),
        Elements::div()
            .direction(Direction::Horizontal)
            .children(vec![
                Text::new("Left").into(),
                Text::new("Right").into(),
            ])
            .into(),
    ])
    .into();

Key Components

  • Node: Virtual representation of UI elements (Element trait objects or Text)
  • Elements: Factory for creating concrete element types (Div, etc.)
  • Element: Trait for element data access (props, children)
  • ElementBuilder: Trait providing fluent builder API for elements
  • VDom: Manages the virtual DOM state and updates
  • Diff: Calculates minimal changes between UI states
  • Render: Translates virtual nodes to terminal output
  • App: Main application lifecycle and event loop
  • Model: Type-safe init-view-update architecture for stateful models