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//! - [`Gauge`]: displays progress percentage using block characters.
43//! - [`LineGauge`]: displays progress as a line.
44//! - [`List`]: displays a list of items and allows selection.
45//! - [`RatatuiLogo`]: displays the Ratatui logo.
46//! - [`RatatuiMascot`]: displays the Ratatui mascot.
47//! - [`Paragraph`]: displays a paragraph of optionally styled and wrapped text.
48//! - [`Scrollbar`]: displays a scrollbar.
49//! - [`Sparkline`]: displays a single dataset as a sparkline.
50//! - [`Table`]: displays multiple rows and columns in a grid and allows selection.
51//! - [`Tabs`]: displays a tab bar and allows selection.
52//!
53//! [`BarChart`]: crate::barchart::BarChart
54//! [`Block`]: crate::block::Block
55//! [`calendar::Monthly`]: crate::calendar::Monthly
56//! [`Canvas`]: crate::canvas::Canvas
57//! [`Chart`]: crate::chart::Chart
58//! [`Clear`]: crate::clear::Clear
59//! [`Gauge`]: crate::gauge::Gauge
60//! [`LineGauge`]: crate::gauge::LineGauge
61//! [`List`]: crate::list::List
62//! [`RatatuiLogo`]: crate::logo::RatatuiLogo
63//! [`RatatuiMascot`]: crate::mascot::RatatuiMascot
64//! [`Paragraph`]: crate::paragraph::Paragraph
65//! [`Scrollbar`]: crate::scrollbar::Scrollbar
66//! [`Sparkline`]: crate::sparkline::Sparkline
67//! [`Table`]: crate::table::Table
68//! [`Tabs`]: crate::tabs::Tabs
69//!
70//! All these widgets are re-exported directly under `ratatui::widgets` in the `ratatui` crate.
71//!
72//! # Crate Organization
73//!
74//! `ratatui-widgets` is part of the Ratatui workspace that was modularized in version 0.30.0.
75//! This crate contains all the built-in widget implementations that were previously part of the
76//! main `ratatui` crate.
77//!
78//! **When to use `ratatui-widgets`:**
79//!
80//! - Building widget libraries that need to compose with built-in widgets
81//! - You want finer-grained dependencies and only need specific widgets
82//! - Creating custom widgets that extend or wrap the built-in ones
83//!
84//! **When to use the main [`ratatui`] crate:**
85//!
86//! - Building applications (recommended - includes everything you need)
87//! - You want the convenience of having all widgets available
88//!
89//! For detailed information about the workspace organization, see [ARCHITECTURE.md].
90//!
91//! [`ratatui`]: https://crates.io/crates/ratatui
92//! [ARCHITECTURE.md]: https://github.com/ratatui/ratatui/blob/main/ARCHITECTURE.md
93#![cfg_attr(feature = "document-features", doc = "\n## Features")]
94#![cfg_attr(feature = "document-features", doc = document_features::document_features!())]
95//!
96//! # Contributing
97//!
98//! Contributions are welcome! Please open an issue or submit a pull request on GitHub. For more
99//! details on contributing, please see the [CONTRIBUTING](CONTRIBUTING.md) document.
100//!
101//! # License
102//!
103//! This project is licensed under the MIT License. See the [LICENSE](../LICENSE) file for details.
104
105#![warn(clippy::std_instead_of_core)]
106#![warn(clippy::std_instead_of_alloc)]
107#![warn(clippy::alloc_instead_of_core)]
108
109extern crate alloc;
110#[cfg(feature = "std")]
111extern crate std;
112
113pub mod barchart;
114pub mod block;
115pub mod borders;
116pub mod canvas;
117pub mod chart;
118pub mod clear;
119pub mod gauge;
120pub mod list;
121pub mod logo;
122pub mod mascot;
123pub mod paragraph;
124pub mod scrollbar;
125pub mod sparkline;
126pub mod table;
127pub mod tabs;
128
129#[cfg(not(feature = "std"))]
130mod polyfills;
131mod reflow;
132
133#[cfg(feature = "calendar")]
134pub mod calendar;