v0.22.0
https://github.com/ratatui/ratatui/releases/tag/v0.22.0
Prelude
We now have a prelude
module! This allows users of the library to easily use ratatui
without a
huge amount of imports.
Aside from the main types that are used in the library, this prelude
also re-exports several
modules to make it easy to qualify types that would otherwise collide. For example:
New widget: Scrollbar
A scrollbar widget has been added which can be used with any Rect
. It can also be customized with
different styles and symbols.
Here are the components of a Scrollbar
:
To use it, render it as a stateful widget along with ScrollbarState
:
Will result in:
Block: support multiple titles
Block
widget now supports having more than one title via Title
widget.
Each title will be rendered with a single space separating titles that are in the same position or alignment. When both centered and non-centered titles are rendered, the centered space is calculated based on the full width of the block, rather than the leftover width.
You can provide various types as the title, including strings, string slices, borrowed strings
(Cow<str>
), spans, or vectors of spans (Vec<Span>
).
It can be used as follows:
Results in:
Barchart: support groups
Barchart
has been improved to support adding multiple bars from different data sets. This can be
done by using the newly added Bar
and BarGroup
objects.
See the barchart example for more information and implementation details.
Stylization shorthands
It is possible to use style shorthands for str
, Span
, and Paragraph
.
A crazy example would be:
This especially helps with concise styling:
Stylize everything
All widgets can be styled now (i.e. set_style
)
Styled
trait is implemented for all the remaining widgets, including:
Barchart
Chart
(includingAxis
andDataset
)Gauge
andLineGauge
List
andListItem
Sparkline
Table
,Row
, andCell
Tabs
Style
Constant styles
Style
s can be constructed in a const
context as follows:
More colors formats
It is now possible to parse hyphenated color names like light-red
via Color::from_str
.
Additionally, all colors from the ANSI color table are supported (though some names are not exactly the same).
gray
is sometimes calledwhite
- this is not supported as we usewhite
for bright whitegray
is sometimes calledsilver
- this is supporteddarkgray
is sometimes calledlight black
orbright black
(both are supported)white
is sometimes calledlight white
orbright white
(both are supported)- we support
bright
andlight
prefixes for all colors - we support
"-"
,"_"
, and" "
as separators for all colors - we support both
gray
andgrey
spellings
For example:
Integrations
Following tools are now integrated into the repository:
cargo-husky
: git pre-push hooksbacon
: background code checks / coveragecommitizen
: conventional commitscargo-deny
: linting dependenciestypos
: spell checker
Other
- Benchmarks added for the
Paragraph
widget - Added underline colors support for
crossterm
backend - Mark some of the low-level functions of
Block
,Layout
andRect
asconst
- The project license has been updated to acknowledge
ratatui
developers