A high-performance TUI framework for Rust with React-style declarative components
cTUI Website · Docs · Examples · Changelog · Contributing · Report a Bug · Request a Feature
cTUI (see-too-eye) is a Rust crate for building terminal user interfaces with a declarative, component-based approach. It brings modern frontend paradigms to the terminal, making it easy to create responsive, animated, and performant TUIs.
- Layer System - Z-index based layering for proper render ordering. Widgets can specify
z_index()to control which elements appear on top. - Event Batching - Efficiently batch and process terminal events. Reduces overhead by coalescing rapid input sequences.
- Component Pooling - Reuse component instances to minimize allocations and improve performance in frequently updated UIs.
- WASM Backend - Compile to WebAssembly for browser-based terminals. Run your TUI in the browser with full feature parity.
- Float Colors -
Color32type for high-precision color manipulation (0.0-1.0 range). Enable with thefloat-colorsfeature. - React-style Components - Declarative components with hooks (
use_state,use_effect) for familiar state management.
Add cTUI to your project:
```shell cargo add ctui ```
Here's a minimal counter application:
```rust use ctui::{component, App, Component, Terminal}; use ctui::hooks::{use_state, use_effect};
#[component] fn Counter() -> impl Component { let (count, set_count) = use_state(0);
use_effect(move || {
println!("Count: {}", count);
}, [count]);
Column::new()
.child(Text::new(&format!("Count: {}", count)))
.child(
Row::new()
.child(Button::new("-").on_click(move || set_count(count - 1)))
.child(Button::new("+").on_click(move || set_count(count + 1)))
)
}
#[tokio::main] async fn main() -> Result<(), Box> { let mut terminal = Terminal::new()?; let app = App::new(Counter {}); terminal.run(app).await } ```
- Docs - Full API documentation on docs.rs
- ARCHITECTURE.md - Crate organization and design decisions
- CHANGELOG.md - Version history and release notes
- Examples - Complete example applications
Get started quickly with project templates:
```shell cargo install ctui-cli ctui new my-app --template counter ```
Available templates:
- `basic` - Minimal hello world application
- `counter` - Counter app with state management
- `todo-app` - Full CRUD todo application
Building something with cTUI? Add a badge to your README:
If cTUI doesn't fit your needs, consider these alternatives:
- ratatui - Imperative TUI library with excellent widget ecosystem
- cursive - ncurses-based TUI library
- iocraft - Declarative TUI library with React-like API
We welcome contributions! Whether you're fixing a bug, adding a feature, or improving documentation, your help makes cTUI better.
Please read the Contributing Guidelines before submitting a pull request. Key points:
- Follow the Code of Conduct
- Use Conventional Commits
- Run
cargo test --allbefore pushing - AI-generated content must follow our AI Content Policy
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
cTUI draws inspiration from several projects:
- ratatui for pushing the Rust TUI ecosystem forward
- React for pioneering the declarative component model
- The Rust community for creating amazing tools and libraries
Built with care by the CortexLM team.