eye-declare #
A declarative, React-like TUI rendering library for Rust, built on Ratatui.
eye-declare provides a component model for building terminal UIs that render inline — content grows into the terminal's native scrollback rather than taking over the full screen. Designed for CLI tools, AI assistants, and interactive prompts where output accumulates and earlier results should remain visible.
use eye_declare::{element, Application, Elements, Spinner, TextBlock};
struct AppState {
messages: Vec<String>,
thinking: bool,
}
fn chat_view(state: &AppState) -> Elements {
element! {
#(for msg in &state.messages {
TextBlock {
Line { Span(text: msg.clone()) }
}
})
#(if state.thinking {
Spinner(key: "thinking", label: "Thinking...")
})
}
}
#[tokio::main]
async fn main() -> std::io::Result<()> {
let (mut app, handle) = Application::builder()
.state(AppState { messages: vec![], thinking: false })
.view(chat_view)
.build()?;
tokio::spawn(async move {
handle.update(|s| s.messages.push("Hello from eye-declare!".into()));
});
app.run().await
}
Key features #
- Inline rendering — content grows downward into terminal scrollback, like normal CLI output
- React-like component model — props, state, reconciliation, and lifecycle hooks
element!macro — JSX-like syntax for composing component trees- Automatic dirty tracking — only changed components re-render
- Frame diffing — minimal ANSI output, no tearing
- Async-first —
Handlesends updates from any thread or async task
Get started #
- Introduction — why eye-declare exists and how it works
- Installation — add it to your project
- Quick Start — build your first inline TUI
Learn #
- The element! Macro — full syntax reference
- Components — the Component trait and composition patterns
- Layout — vertical and horizontal stacking
- Lifecycle Hooks — intervals, mount/unmount, autofocus
- Events and Focus — keyboard handling and focus management
- Context — sharing data without prop-drilling
- Reconciliation — how state survives rebuilds
- Application — the Application API and running modes
Reference #
- Built-in Components — TextBlock, Spinner, Markdown, VStack, HStack, Column
- Terminal Options — Ctrl+C behavior, keyboard protocols, bracketed paste
- Imperative API — InlineRenderer for direct control
Status #
eye-declare is in early development — expect breaking changes before 1.0.
License #
MIT