~ A ratatui framework inspired by Elm and React ~
Get started ยท Standard Library ยท Documentation
Developed by @veeso
Current version: 1.9.2 (04/03/2024)
- tui-realm
tui-realm is a framework for tui and ratatui to simplify the implementation of terminal user interfaces adding the possibility to work with re-usable components with properties and states, as you'd do in React. But that's not all: the components communicate with the ui engine via a system based on Messages and Events, providing you with the possibility to implement update
routines as happens in Elm. In addition, the components are organized inside the View, which manages mounting/umounting, focus and event forwarding for you.
And that's also explains the reason of the name: Realm stands for React and Elm.
tui-realm also comes with a standard library of components, which can be added to your dependencies, that you may find very useful. Don't worry, they are optional if you don't want to use them ๐, just follow the guide in get started.
See tui-realm in action in the Example or if you want to read more about tui-realm start reading the official guide HERE.
- โจ๏ธ Event-driven
- โ๏ธ Based on React and Elm
- ๐ฒ Boilerplate code
- ๐ Quick-setup
- ๐ฏ Single focus and states management
- ๐ Easy to learn
- ๐ค Adaptable to any use case
โ ๏ธ Warning: currently tui-realm supports these backends: crossterm, termion
If you want the default features, just add tuirealm 1.x version:
tuirealm = "^1.9.0"
otherwise you can specify the features you want to add:
tuirealm = { version = "^1.9.0", default-features = false, features = [ "derive", "serialize", "termion" ] }
Supported features are:
derive
(default): add the#[derive(MockComponent)]
proc macro to automatically implementMockComponent
forComponent
. Read more.serialize
: add the serialize/deserialize trait implementation forKeyEvent
andKey
.tui
: use the tui-rs terminal UI libraryratatui
: use the ratatui terminal UI librarycrossterm
: use the crossterm terminal backendtermion
: use the termion terminal backend
Deprecated feature flags:
with-crossterm
with-termion
โ ๏ธ You can enable only one backend at the time and at least one must be enabled in order to build.
โ You don't need tui as a dependency, since you can access to tui types viause tuirealm::tui::
This library supports two backends: crossterm
and termion
, and two high
level terminal TUI libraries: tui
and ratatui
. Whenever you explicitly
declare any of the TUI library or backend feature sets you should disable the
crate's default features.
โ You can never have more than one backend and one UI library enabled at the same time
Example using the termion backend:
tuirealm = { version = "^1.9.0", default-features = false, features = [ "termion", "derive", "tui" ] }
Example using the ratatui UI library:
tuirealm = { version = "^1.9.0", default-features = false, features = [ "ratatui", "derive", "crossterm" ]}
View how to implement a tui-realm application in the related guide.
Still confused about how tui-realm works? Don't worry, try with the examples:
-
demo: a simple application which shows how tui-realm works
cargo run --example demo
Tui-realm comes with an optional standard library of components I thought would have been useful for most of the applications.
If you want to use it, just add the tui-realm-stdlib to your Cargo.toml
dependencies.
These components are not included in tui-realm, but have been developed by other users. I like advertising other's contents, so here you can find a list of components you may find useful for your next tui-realm project ๐.
- tui-realm-textarea A textarea/editor component developed by @veeso
- tui-realm-treeview A treeview component developed by @veeso
Want to add yours? Open an issue using the New app/component
template ๐
The developer documentation can be found on Rust Docs at https://docs.rs/tuirealm
Want to add yours? Open an issue using the New app/component
template ๐
If you like tui-realm and you're grateful for the work I've done, please consider a little donation ๐ฅณ
You can make a donation with one of these platforms:
Contributions, bug reports, new features and questions are welcome! ๐ If you have any question or concern, or you want to suggest a new feature, or you want just want to improve tui-realm, feel free to open an issue or a PR.
Please follow our contributing guidelines
View tui-realm's changelog HERE
tui-realm is licensed under the MIT license.
You can read the entire license HERE