tui_overlay/lib.rs
1//! Composable overlay widget for [Ratatui]: drawers, modals, popovers, and toasts
2//! from a single configurable primitive.
3//!
4//! # Quick start
5//!
6//! ```rust
7//! use std::time::Duration;
8//! use ratatui_core::layout::Constraint;
9//! use tui_overlay::{Anchor, Easing, Overlay, OverlayState, Slide};
10//!
11//! let overlay = Overlay::new()
12//! .anchor(Anchor::Right)
13//! .slide(Slide::Right)
14//! .width(Constraint::Percentage(30));
15//!
16//! let mut state = OverlayState::new()
17//! .with_duration(Duration::from_millis(150))
18//! .with_easing(Easing::EaseOut);
19//!
20//! state.open();
21//! ```
22//!
23//! # Rendering
24//!
25//! Render main content first, then the overlay (which dims and draws chrome),
26//! then body content into the exposed inner area.
27//!
28//! ```rust,ignore
29//! // 1. Main UI
30//! frame.render_widget(dashboard, area);
31//!
32//! // 2. Overlay (backdrop + chrome)
33//! frame.render_stateful_widget(overlay, area, &mut state);
34//!
35//! // 3. Body content into the overlay
36//! if let Some(inner) = state.inner_area() {
37//! frame.render_widget(detail_panel, inner);
38//! }
39//! ```
40//!
41//! Call [`OverlayState::tick`] with elapsed time each frame to drive slide animation.
42//!
43//! For click-outside-to-dismiss, use [`OverlayState::overlay_rect`] for hit testing.
44//!
45//! [Ratatui]: https://ratatui.rs
46
47mod anchor;
48mod backdrop;
49mod easing;
50mod layout;
51mod overlay;
52mod slide;
53mod state;
54
55pub use anchor::Anchor;
56pub use backdrop::Backdrop;
57pub use easing::Easing;
58pub use overlay::Overlay;
59pub use slide::Slide;
60pub use state::OverlayState;