limit-tui
Terminal UI components with Virtual DOM rendering for Rust applications.
Build rich terminal interfaces with a React-like component model, powered by Ratatui. Features declarative rendering, diff-based updates, and built-in syntax highlighting.
Part of the Limit ecosystem.
Features
- Virtual DOM: React-like component model with diff-based rendering
- Pre-built components: Chat views, inputs, spinners, progress bars, select menus
- Flexbox layout: CSS Flexbox-inspired layout system
- Syntax highlighting: Built-in support for 150+ languages via Syntect
- Event handling: Keyboard, mouse, and resize events
- Zero-cost abstractions: Efficient rendering with minimal allocations
Installation
Add to your Cargo.toml:
[]
= "0.0.25"
Quick Start
Basic Application
use ;
use CrosstermBackend;
Virtual DOM
Build UIs declaratively with VNode:
use ;
let ui = div
.style
.children;
Diff-Based Updates
The Virtual DOM efficiently computes minimal changes:
use ;
let old_tree = text;
let new_tree = text;
let patches = diff;
// patches = [Patch::SetText(0, "Hello, World!")]
apply?;
Components
ChatView
Display conversation messages with role-based styling:
use ;
let chat = new;
InputPrompt
Interactive text input with placeholder:
use InputPrompt;
let input = new
.prefix
.show_cursor;
SelectPrompt
Single/multi-select menus:
use ;
let menu = new
.title;
match menu.result
Spinner & ProgressBar
Loading indicators:
use ;
let spinner = new.label;
let progress = new.label;
Layout System
Flexbox-inspired layout:
use ;
let layout = new
.direction
.justify_content
.align_items
.gap;
Syntax Highlighting
use SyntaxHighlighter;
let highlighter = new;
let code = highlighter.highlight;
// Returns styled text with syntax colors
API Reference
| Module | Description |
|---|---|
vdom |
Virtual DOM types and diff algorithm |
components |
Pre-built UI components |
layout |
Flexbox layout system |
syntax |
Syntax highlighting |
backend |
Ratatui integration |
License
MIT