Skip to main content

Crate limit_tui

Crate limit_tui 

Source
Expand description

§limit-tui

Crates.io Docs.rs License: MIT

Terminal UI components with Virtual DOM rendering for Rust applications.

Build rich terminal interfaces with a component model, powered by Ratatui. Features declarative rendering, diff-based updates, and built-in syntax highlighting.

§Features

  • Virtual DOM: Component model with diff-based rendering
  • Pre-built components: Chat views, inputs, spinners, progress bars, select menus
  • Syntax highlighting: Built-in support for 150+ languages via Syntect
  • Event handling: Keyboard, mouse, and resize events

§Virtual DOM

Build UIs with VNode:

use limit_tui::vdom::VNode;
use std::collections::HashMap;

let ui = VNode::Element {
    tag: "div".to_string(),
    attrs: HashMap::new(),
    children: vec![
        VNode::Text("Hello, World!".to_string()),
    ],
};

§Diff-Based Updates

The Virtual DOM computes minimal changes:

use limit_tui::vdom::{diff, apply, VNode};

let old_tree = VNode::Text("Hello".to_string());
let new_tree = VNode::Text("Hello, World!".to_string());

let patches = diff(&old_tree, &new_tree);
// patches contains minimal changes to transform old → new

§Components

ComponentDescription
ChatViewConversation display with role-based styling
InputPromptInteractive text input with placeholder
SelectPromptSingle/multi-select menus
SpinnerLoading spinner with label
ProgressBarProgress indicator

§Syntax Highlighting

use limit_tui::SyntaxHighlighter;

let highlighter = SyntaxHighlighter::new()?;

let code = highlighter.highlight_to_spans(r#"
fn main() {
    println!("Hello, World!");
}
"#, "rust")?;

// Returns styled spans with syntax colors

Re-exports§

pub use backend::render_vdom_to_ratatui;
pub use backend::run_event_loop;
pub use backend::RatatuiBackend;
pub use components::ChatView;
pub use components::InputPrompt;
pub use components::InputResult;
pub use components::Message;
pub use components::ProgressBar;
pub use components::Role;
pub use components::SelectPrompt;
pub use components::SelectResult;
pub use components::Spinner;
pub use layout::AlignItems;
pub use layout::FlexDirection;
pub use layout::FlexStyle;
pub use layout::FlexboxLayout;
pub use layout::JustifyContent;
pub use syntax::SyntaxHighlighter;
pub use vdom::apply;
pub use vdom::diff;
pub use vdom::render;
pub use vdom::Patch;
pub use vdom::VNode;

Modules§

backend
components
layout
syntax
vdom