Skip to content

microsandbox/rxtui

Repository files navigation

rxtui-dark rxtui-light

———   reactive terminal UI framework for rust   ———



Warning

This project is in early development. APIs may change, and bugs may exist.

WHY RXTUI?

Terminal UIs have traditionally been painful to build. You either work with low-level escape sequences (error-prone and tedious) or use immediate-mode libraries that require you to manage all state manually. RxTUI takes a different approach.

We bring the retained-mode, component-based architecture that revolutionized web development to the terminal:

  • Declarative UI - Describe what your UI should look like, not how to change it
  • True Composability - Build complex apps from simple, reusable components
  • Best of Both Worlds - Elm's message architecture meets React's components
  • TUI Optimizations - Automatic diffing, dirty tracking, and minimal redraws

align demo

QUICK START

1  Install RxTUI

Add to your Cargo.toml:

[dependencies]
rxtui = "0.1"

2  Create Your First App

A simple working example showing separation of state management and UI building:

use rxtui::prelude::*;

#[derive(Component)]
struct Counter;

impl Counter {
    #[update]
    fn update(&self, _ctx: &Context, msg: &str, mut count: i32) -> Action {
        match msg {
            "inc" => Action::update(count + 1),
            "dec" => Action::update(count - 1),
            _ => Action::exit(),
        }
    }

    #[view]
    fn view(&self, ctx: &Context, count: i32) -> Node {
        node! {
            div(
                pad: 2,
                align: center,
                w_pct: 1.0,
                gap: 1,
                @key(up): ctx.handler("inc"),
                @key(down): ctx.handler("dec"),
                @key(esc): ctx.handler("exit")
            ) [
                text(format!("Count: {count}"), color: white, bold),
                text("use ↑/↓ to change, esc to exit", color: bright_black)
            ]
        }
    }
}

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

3  Run Your App

cargo run
counter demo
• • •

DOCUMENTATION

Document Description
Examples Collection of example apps
Documentation Complete framework documentation
Tutorial Step-by-step guide from basics to advanced
API Reference Detailed API documentation
Quick Reference Handy cheat sheet for common patterns
Implementation Internal architecture details
• • •

DEVELOPMENT

Want to contribute? We'd love to have you!

• • •

LICENSE

This project is licensed under the Apache License 2.0.

About

Reactive terminal interfaces for Rust. Because CLIs deserve better.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages