ratatui/ratatui-widgets
Josh McKinney a41c97b413
chore: move unstable widget refs to ratatui (#1491)
These are less stable than the non-ref traits as we have not yet
committed to the exact API. This change moves them to ratatui from
ratatui-core.

To facilitate this:
- implementations of WidgetRef for all internal widgets are removed and
  replaced with implementations of Widget for references to those
  widgets.
- Widget is now implemented for Option<W> where W: Widget, allowing for
  rendering of optional widgets.
- The blanket implementation of Widget for WidgetRef is reversed, to be
  a blanket implementation of WidgetRef for all &W where W: Widget.

BREAKING CHANGE: implementations of WidgetRef no longer have a blanket
implementation of Widget, so Widgets should generally implement the
Widget trait on a reference to the widget rather than implementing
WidgetRef directly. This has the advantage of not requiring unstable
features to be enabled.

Part of: https://github.com/ratatui/ratatui/issues/1388

Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
2024-11-18 14:19:21 -08:00
..
src chore: move unstable widget refs to ratatui (#1491) 2024-11-18 14:19:21 -08:00
Cargo.toml chore: move unstable widget refs to ratatui (#1491) 2024-11-18 14:19:21 -08:00
README.md docs: improve docs for workspace crates (#1490) 2024-11-18 02:03:44 +03:00

Ratatui Widgets

Crates.io Documentation License

ratatui-widgets contains all the widgets that were previously part of the Ratatui crate. It is meant to be used in conjunction with ratatui, which provides the core functionality for building terminal user interfaces.

Most applications shouldn't need to depend directly on ratatui-widgets, ratatui crate re-exports all the widgets from this crate. However, if you are building a widget library that internally uses these widgets, or if you prefer finer grained dependencies, you may want to depend on this crate rather than transitively through the ratatui crate.

Previously, a crate named ratatui-widgets was published with some formative ideas about an eventual Ratatui framework. That crate is now move to tui-framework-experiment, pending a new name.

Installation

Run the following command to add this crate to your project:

cargo add ratatui-widgets

Available Widgets

  • BarChart: displays multiple datasets as bars with optional grouping.
  • Block: a basic widget that draws a block with optional borders, titles, and styles.
  • calendar::Monthly: displays a single month.
  • Canvas: draws arbitrary shapes using drawing characters.
  • Chart: displays multiple datasets as lines or scatter graphs.
  • Clear: clears the area it occupies. Useful to render over previously drawn widgets.
  • Gauge: displays progress percentage using block characters.
  • LineGauge: displays progress as a line.
  • List: displays a list of items and allows selection.
  • RatatuiLogo: displays the Ratatui logo.
  • Paragraph: displays a paragraph of optionally styled and wrapped text.
  • Scrollbar: displays a scrollbar.
  • Sparkline: displays a single dataset as a sparkline.
  • Table: displays multiple rows and columns in a grid and allows selection.
  • Tabs: displays a tab bar and allows selection.

All these widgets are re-exported directly under ratatui::widgets in the ratatui crate.

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub. For more details on contributing, please see the CONTRIBUTING document.

License

This project is licensed under the MIT License. See the LICENSE file for details.