Expand description
§limit-tui
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
| Component | Description |
|---|---|
ChatView | Conversation display with role-based styling |
InputPrompt | Interactive text input with placeholder |
SelectPrompt | Single/multi-select menus |
Spinner | Loading spinner with label |
ProgressBar | Progress 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 colorsRe-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;