
Resolves https://github.com/ratatui/ratatui/issues/1951 BREAKING CHANGE: Old `Flex::SpaceAround` behavior is available by using `Flex::SpaceEvenly` and new `Flex::SpaceAround` now distributes space evenly around each element except the middle spacers are twice the size of first and last elements With this change, the following variants of `Flex` are supported: - `Flex::Start`: Aligns items to the start; excess space appears at the end. - `Flex::End`: Aligns items to the end; excess space appears at the start. - `Flex::Center`: Centers items with equal space on both sides. - `Flex::SpaceAround` (**new**): Distributes space _around_ items; space between items is _twice_ the edge spacing. - `Flex::SpaceBetween`: Distributes space _evenly between_ items except no space at the edges. - `Flex::SpaceEvenly` (**previously `Flex::SpaceAround`**): Distributes space _evenly between_ items and edges. - `Flex::Legacy`: Preserves legacy behavior, placing all excess space at the end. This aligns behavior of `Flex` with CSS flexbox more closely. The following is a screenshot in action: <img width="1090" alt="image" src="https://github.com/user-attachments/assets/2c7cd797-27bd-4242-a824-4565d369227b" /> --------- Co-authored-by: Jagoda Estera Ślązak <128227338+j-g00da@users.noreply.github.com>
Ratatui Core
ratatui-core is the core library of the ratatui project, providing the essential building blocks for creating rich terminal user interfaces in Rust.
Why ratatui-core
?
The ratatui-core
crate is split from the main ratatui
crate
to offer better stability for widget library authors. Widget libraries should generally depend
on ratatui-core
, benefiting from a stable API and reducing the need for frequent updates.
Applications, on the other hand, should depend on the main ratatui
crate, which includes
built-in widgets and additional features.
Installation
Add ratatui-core
to your Cargo.toml
:
cargo add ratatui-core
Crate Organization
ratatui-core
is part of the Ratatui workspace that was modularized in version 0.30.0 to
improve compilation times, API stability, and dependency management. This crate provides the
foundational types and traits that other crates in the workspace depend on.
When to use ratatui-core
:
- Building widget libraries that implement
Widget
orStatefulWidget
- Creating lightweight applications that don't need built-in widgets
- You want minimal dependencies and faster compilation times
- You need maximum API stability (core types change less frequently)
When to use the main ratatui
crate:
- Building applications that use built-in widgets
- You want convenience and don't mind slightly longer compilation times
- You need backend implementations and terminal management utilities
For detailed information about the workspace organization, see ARCHITECTURE.md.
Contributing
We welcome contributions from the community! Please see our CONTRIBUTING guide for more details on how to get involved.
License
This project is licensed under the MIT License. See the LICENSE file for details.