lv-tui 0.1.1

A reactive TUI framework for Rust, inspired by Textual and React
Documentation

lv-tui

A reactive TUI framework for Rust. Component tree, reactive state, CSS-like styling, event bubbling, focus management — everything you need to build complex terminal applications.

use lv_tui::prelude::*;
use lv_tui::Component;

#[derive(Component)]
struct Counter {
    #[reactive(paint, copy)]
    count: i32,
}

impl Counter {
    fn new() -> Self { Self { count: 0 } }

    fn render(&self, cx: &mut RenderCx) {
        cx.line(format!("count: {}", self.get_count()));
        cx.line("press + to increment, q to quit");
    }

    fn event(&mut self, event: &Event, cx: &mut EventCx) {
        if event.is_key(Key::Char('+')) { self.set_count(self.get_count() + 1, cx); }
        if event.is_key(Key::Char('q')) { cx.quit(); }
    }
}

fn main() -> lv_tui::Result<()> {
    App::new(Counter::new()).run()
}

Features

  • Component tree — compose UIs with Column, Row, Stack, Block, Scroll, Overlay
  • Reactive state#[reactive(paint)] auto-triggers repaint on change
  • Event bubbling — Capture → Target → Bubble with stop_propagation()
  • Focus management — Tab/Shift+Tab navigation with Focus/Blur events
  • CSS-like stylesheets — type/class/id selectors with style inheritance
  • Unicode — CJK/Emoji wide characters, text wrap, truncation, alignment
  • Async taskscx.spawn() for background work with TaskComplete events
  • Debug view — press d to visualize component borders and labels

Widgets

Widget Description
Label Text display with styling
Input Single-line text input with cursor
Column Vertical layout container
Row Horizontal layout container
Stack Layered/z-order container
Block Border + padding wrapper with optional title
Scroll Scrollable content container
Overlay Modal dialog with background dimming

Getting Started

[dependencies]
lv-tui = "0.1"
cargo run --example counter
cargo run --example demo_app

License

MIT