v0.21.0
https://github.com/ratatui/ratatui/releases/tag/v0.21.0
New backend: termwiz
ratatui
supports a new backend called termwiz
which is a “Terminal Wizardry” crate that powers
wezterm.
To use it, enable the termwiz
feature in Cargo.toml
:
Then you can utilize TermwizBackend
object for creating a terminal. Here is a simple program that
shows a text on the screen for 5 seconds using ratatui
+ termwiz
:
New widget: Calendar
A calendar widget has been added which was originally a part of the extra-widgets repository.
Since this new widget depends on time
crate, we gated it behind widget-calendar
feature to avoid
an extra dependency:
Here is the example usage:
Results in:
New widget: Circle
Circle
widget has been added with the use-case of showing an accuracy radius on the world map.
Here is an example of how to use it with Canvas
:
Results in:
Inline Viewport
This was a highly requested feature and the original implementation was done by @fdehau himself. Folks at Atuin completed the implementation and we are happy to finally have this incorporated in the new release!
An inline viewport refers to a rectangular section of the terminal window that is set aside for displaying content.
In the repository, there is an example that simulates downloading multiple files in parallel: https://github.com/ratatui/ratatui/blob/main/examples/inline.rs
Block: title on bottom
Before you could only put the title on the top row of a Block. Now you can put it on the bottom row! Revolutionary.
For example, place the title on the bottom and center:
Results in:
Block: support adding padding
If we want to render a widget inside a Block
with a certain distance from its borders, we need to
create another Layout
element based on the outer Block
, add a margin and render the Widget
into it. Adding a padding property on the block element skips the creation of this second Layout.
This property works especially when rendering texts, as we can just create a block with padding and use it as the text wrapper:
Rendering another widget should be easy too, using the .inner
method:
Text: display secure data
A new type called Masked
is added for text-related types for masking data with a mask character.
The example usage is as follows:
Results in:
border!
macro
A border!
macro has been added that takes TOP
, BOTTOM
, LEFT
, RIGHT
, and ALL
and returns
a Borders
object.
An empty border!()
call returns NONE
.
For example:
This is gated behind a macros
feature flag to ensure short build times. To enable it, update
Cargo.toml
as follows:
Going forward, we will most likely put the new macros behind macros
feature as well.
Color: support conversion from String
Have you ever needed this conversion?
Don’t worry, we got you covered:
Spans
-> Line
Line
is a significantly better name over Spans
as the plural causes confusion and the type
really is a representation of a line of text made up of spans.
So, Spans
is renamed as Line
and a deprecation notice has been added.
See https://github.com/ratatui/ratatui/pull/178 for more discussion.
Other features
List
now has alen()
method for returning the number of itemsSparkline
now has adirection()
method for specifying the render direction (left to right / right to left)Table
andList
states now haveoffset()
andoffset_mut()
methods- Expose the test buffer (
TestBackend
) withDisplay
implementation
New apps
Here is the list of applications that has been added:
- oxycards: quiz card application built within the terminal.
- twitch-tui: twitch chat in the terminal.
- tenere: TUI interface for LLMs.
Also, we moved APPS.md
file to the
Wiki so check it out for more
applications built with ratatui
!
Migration from tui-rs
We put together a migration guide at the Wiki: Migrating from TUI
Also, the minimum supported Rust version is 1.65.0
Contributing
Any contribution is highly appreciated! There are contribution guidelines for getting started.
Feel free to submit issues and throw in ideas!
If you are having a problem with ratatui
or want to contribute to the project or just want to
chit-chat, feel free to join our Discord server!