ratatui_widgets/lib.rs
1#![no_std]
2// show the feature flags in the generated documentation
3#![cfg_attr(docsrs, feature(doc_cfg))]
4#![doc(
5 html_logo_url = "https://raw.githubusercontent.com/ratatui/ratatui/main/assets/logo.png",
6 html_favicon_url = "https://raw.githubusercontent.com/ratatui/ratatui/main/assets/favicon.ico"
7)]
8#![warn(missing_docs)]
9//! **ratatui-widgets** contains all the widgets that were previously part of the [Ratatui] crate.
10//! It is meant to be used in conjunction with `ratatui`, which provides the core functionality for
11//! building terminal user interfaces.
12//!
13//! [Ratatui]: https://crates.io/crates/ratatui
14//!
15//! Most applications shouldn't need to depend directly on `ratatui-widgets`, `ratatui` crate
16//! re-exports all the widgets from this crate. However, if you are building a widget library that
17//! internally uses these widgets, or if you prefer finer grained dependencies, you may want to
18//! depend on this crate rather than transitively through the `ratatui` crate.
19//!
20//! Previously, a crate named `ratatui-widgets` was published with some formative ideas about an
21//! eventual Ratatui framework. That crate has now moved to [tui-framework-experiment], pending a
22//! new name.
23//!
24//! [tui-framework-experiment]: https://crates.io/crates/tui-framework-experiment
25//!
26//! # Installation
27//!
28//! Run the following command to add this crate to your project:
29//!
30//! ```sh
31//! cargo add ratatui-widgets
32//! ```
33//!
34//! # Available Widgets
35//!
36//! - [`BarChart`]: displays multiple datasets as bars with optional grouping.
37//! - [`Block`]: a basic widget that draws a block with optional borders, titles, and styles.
38//! - [`calendar::Monthly`]: displays a single month.
39//! - [`Canvas`]: draws arbitrary shapes using drawing characters.
40//! - [`Chart`]: displays multiple datasets as lines or scatter graphs.
41//! - [`Clear`]: clears the area it occupies. Useful to render over previously drawn widgets.
42//! - [`Fill`]: paints every cell in its area with a single repeated symbol and style.
43//! - [`Gauge`]: displays progress percentage using block characters.
44//! - [`LineGauge`]: displays progress as a line.
45//! - [`List`]: displays a list of items and allows selection.
46//! - [`RatatuiLogo`]: displays the Ratatui logo.
47//! - [`RatatuiMascot`]: displays the Ratatui mascot.
48//! - [`Paragraph`]: displays a paragraph of optionally styled and wrapped text.
49//! - [`Scrollbar`]: displays a scrollbar.
50//! - [`Sparkline`]: displays a single dataset as a sparkline.
51//! - [`Table`]: displays multiple rows and columns in a grid and allows selection.
52//! - [`Tabs`]: displays a tab bar and allows selection.
53//!
54//! [`BarChart`]: crate::barchart::BarChart
55//! [`Block`]: crate::block::Block
56//! [`calendar::Monthly`]: crate::calendar::Monthly
57//! [`Canvas`]: crate::canvas::Canvas
58//! [`Chart`]: crate::chart::Chart
59//! [`Clear`]: crate::clear::Clear
60//! [`Fill`]: crate::fill::Fill
61//! [`Gauge`]: crate::gauge::Gauge
62//! [`LineGauge`]: crate::gauge::LineGauge
63//! [`List`]: crate::list::List
64//! [`RatatuiLogo`]: crate::logo::RatatuiLogo
65//! [`RatatuiMascot`]: crate::mascot::RatatuiMascot
66//! [`Paragraph`]: crate::paragraph::Paragraph
67//! [`Scrollbar`]: crate::scrollbar::Scrollbar
68//! [`Sparkline`]: crate::sparkline::Sparkline
69//! [`Table`]: crate::table::Table
70//! [`Tabs`]: crate::tabs::Tabs
71//!
72//! All these widgets are re-exported directly under `ratatui::widgets` in the `ratatui` crate.
73//!
74//! # Crate Organization
75//!
76//! `ratatui-widgets` is part of the Ratatui workspace that was modularized in version 0.30.0.
77//! This crate contains all the built-in widget implementations that were previously part of the
78//! main `ratatui` crate.
79//!
80//! **When to use `ratatui-widgets`:**
81//!
82//! - Building widget libraries that need to compose with built-in widgets
83//! - You want finer-grained dependencies and only need specific widgets
84//! - Creating custom widgets that extend or wrap the built-in ones
85//!
86//! **When to use the main [`ratatui`] crate:**
87//!
88//! - Building applications (recommended - includes everything you need)
89//! - You want the convenience of having all widgets available
90//!
91//! For detailed information about the workspace organization, see [ARCHITECTURE.md].
92//!
93//! [`ratatui`]: https://crates.io/crates/ratatui
94//! [ARCHITECTURE.md]: https://github.com/ratatui/ratatui/blob/main/ARCHITECTURE.md
95#![cfg_attr(feature = "document-features", doc = "\n## Features")]
96#![cfg_attr(feature = "document-features", doc = document_features::document_features!())]
97//!
98//! # Contributing
99//!
100//! Contributions are welcome! Please open an issue or submit a pull request on GitHub. For more
101//! details on contributing, please see the [CONTRIBUTING](CONTRIBUTING.md) document.
102//!
103//! # License
104//!
105//! This project is licensed under the MIT License. See the [LICENSE](../LICENSE) file for details.
106
107#![warn(clippy::std_instead_of_core)]
108#![warn(clippy::std_instead_of_alloc)]
109#![warn(clippy::alloc_instead_of_core)]
110
111extern crate alloc;
112#[cfg(feature = "std")]
113extern crate std;
114
115pub mod barchart;
116pub mod block;
117pub mod borders;
118pub mod canvas;
119pub mod chart;
120pub mod clear;
121pub mod fill;
122pub mod gauge;
123pub mod list;
124pub mod logo;
125pub mod mascot;
126pub mod paragraph;
127pub mod scrollbar;
128pub mod sparkline;
129pub mod table;
130pub mod tabs;
131
132#[cfg(not(feature = "std"))]
133mod polyfills;
134mod reflow;
135
136mod as_ref;
137#[cfg(feature = "calendar")]
138pub mod calendar;