Skip to main content

tui_kit/
lib.rs

1//! `tui-kit` — reusable TUI theme, widget frames, and layout helpers.
2//!
3//! Built on top of [ratatui](https://github.com/ratatui-org/ratatui).
4//! Designed to be shared across multiple terminal-UI projects that follow
5//! the same visual design language.
6//!
7//! ## Modules
8//!
9//! | Module     | Contents |
10//! |------------|----------|
11//! | [`theme`]  | [`Theme`] struct — the full color/style palette |
12//! | [`block`]  | [`block::panel_block`], [`block::popup_block`], [`block::widget_title`], [`block::focusable_block`] |
13//! | [`footer`] | [`render_footer`], [`render_footer_with_app`], [`keybind_spans`] — keybind bar |
14//! | [`tabs`]   | [`tabs::tab_line`] — horizontal tab-bar line for block titles |
15//! | [`popup`]  | [`popup::centered_popup`] — centered overlay area + Clear |
16//! | [`leader`] | [`render_leader_bar`] — vim-style leader key popup |
17//! | [`mouse`]  | [`mouse_hit`] — hit-test a click against a widget [`Rect`] |
18//! | [`toast`]  | [`render_toasts`] — stacked notification toasts |
19//! | [`list`]   | [`list::render_list`] — scrollable focusable list |
20//! | [`form`]   | [`render_form`] — multi-field input form |
21//! | [`kv`]     | [`kv::render_kv_table`] — two-column key/value table |
22//!
23//! ## Keybind bar convention
24//!
25//! Every project should show a footer keybind bar using [`render_footer`].
26//! The visual format is identical across all projects:
27//!
28//! ```text
29//! Navigate: j/k  |  Open: Enter  |  Leader: space  |  Quit: q
30//! ```
31//!
32//! Keys are styled with [`Theme::shortcut_key`] (yellow), actions and
33//! separators with [`Theme::hint`] (dark gray).
34//!
35//! Build pairs contextually based on the active UI layer (popup vs main screen):
36//!
37//! ```rust
38//! let mut pairs: Vec<(&str, &str)> = Vec::new();
39//! if some_popup_open {
40//!     pairs.push(("Esc",   "close"));
41//!     pairs.push(("Enter", "confirm"));
42//! } else {
43//!     pairs.push(("j/k",   "navigate"));
44//!     pairs.push(("space", "leader"));
45//!     pairs.push(("q",     "quit"));
46//! }
47//! render_footer(f, footer_area, &pairs, &theme);
48//! ```
49
50pub mod block;
51pub mod footer;
52pub mod form;
53pub mod kv;
54pub mod leader;
55pub mod list;
56pub mod log;
57pub mod mouse;
58pub mod picker;
59pub mod popup;
60pub mod tabs;
61pub mod theme;
62pub mod toast;
63pub mod wizard;
64
65pub use block::render_scrollbar;
66pub use footer::{keybind_spans, render_footer, render_footer_with_app};
67pub use mouse::{list_item_at, mouse_hit, paragraph_line_at};
68pub use form::{
69    FieldInput, FormEvent, FormField, FormState, FormStyle,
70    error_lines, input_row, label_prefix, render_form, render_form_with, select_row, wrap_chars,
71};
72pub use kv::KvRow;
73pub use leader::{LeaderNode, LeaderResult, LeaderState, render_leader_bar};
74pub use list::{ListItem, ListState};
75pub use log::{LogEntry, LogLevel};
76pub use picker::{PickerItem, PickerState, render_picker};
77pub use theme::Theme;
78pub use toast::{Toast, ToastLevel, render_toasts};
79pub use wizard::{ArrayEditSession, ArrayState, WizardEvent, WizardStep, WizardStepKind, WizardState, render_wizard};