#tui #react


TUI widgets using a react-like paradigm, allowing mutable component state and render properties

19 releases (12 breaking)

0.20.0 May 11, 2023
0.19.0 Sep 12, 2022
0.17.0 Jan 23, 2022
0.16.0 Aug 4, 2021
0.1.2 Jun 15, 2019

#134 in Command-line interface

Download history 886/week @ 2023-06-03 674/week @ 2023-06-10 561/week @ 2023-06-17 599/week @ 2023-06-24 618/week @ 2023-07-01 596/week @ 2023-07-08 548/week @ 2023-07-15 543/week @ 2023-07-22 745/week @ 2023-07-29 734/week @ 2023-08-05 762/week @ 2023-08-12 950/week @ 2023-08-19 530/week @ 2023-08-26 829/week @ 2023-09-02 723/week @ 2023-09-09 435/week @ 2023-09-16

2,587 downloads per month
Used in 9 crates (3 directly)

MIT license

349 lines

tui-react is a library to enable components with state, and with properties provided per render

Please note that this crate is early in development and build for the needs of dua.

How it works

It uses the TUI infrastructure Terminal, but alters it to not enforce implementing the Widget trait. It provides only a single, optional, trait called TopLevelComponent, which makes it convenient to draw its implementors with Terminal::render(..). However, since this enforces the absence of refernces in your state, it's probably not suitable for most.

Instead, any struct can implement render methods or functions, and freely write into the terminal. That way, one can leverage everything Rust has to offer, which allows stateful components which work in your favor. Thus, this crate does away with 'one size fits all' render implementations, greatly adding to flexibility.

State that one wants within the component for instance could be the scoll location. Alternatively, one can configure windows by altering their public state.

What's the relation to TUI / Ratatui?

This project couldn't exist without TUI, and is happy to provide an alternative set of components for use in command-line applications. Ratatui is the continuation of the tui project.

Why tui-react?

I kept having a terrible feeling when managing state with tui widgets when writing dua, and after trying many things, I realized what the problem actually was. It took me some time to realize it's not possible to have stateful components in with TUI, and I admire the smarts that went into the API design! After all, it effectively prohibited this! Amazing!

That's why I implemented my own terminal and some key components, based on the ones provided by TUI, which can serve as standard building blocks in a stateful world.

Thus far, the experience was fantastic, and it feels much better than before. Let's see what happens with it.


v0.4.1 - Simplify block_width() function

v0.2.1 - add license file to crate


~33K SLoC