Expand description
Popover widget for anchored floating content.
Popover renders a lightweight floating panel positioned relative to an
anchor rectangle. It automatically flips placement when there isn’t enough
space, making it suitable for tooltips, dropdowns, and context menus.
§Migration rationale
Web frameworks use portals, popovers, and floating-ui for content that renders outside the normal document flow. This widget provides an explicit, terminal-native equivalent that the migration code emitter can target.
§Differences from Modal
- No backdrop: Popover renders only the content, not a full-screen overlay
- Anchor-relative positioning: Content floats near a reference element
- Auto-flip: Placement adjusts to stay within viewport bounds
- Lightweight: No focus trapping or animation built in (compose with FocusTrap if needed)
§Example
ⓘ
use ftui_widgets::popover::{Popover, Placement};
use ftui_layout::Rect;
let anchor = Rect::new(10, 5, 20, 1); // The button/element to anchor to
let popover = Popover::new(anchor, Placement::Below)
.width(30)
.max_height(10)
.with_border(true);
// Render content inside the popover
popover.render_with(area, frame, |content_area, frame| {
// Draw your dropdown/tooltip content here
});Structs§
- Popover
- Configuration for a popover widget.
Enums§
- Placement
- Where to place the popover relative to the anchor.