#[non_exhaustive]pub struct Popup<'content, W> {
pub body: W,
pub title: Line<'content>,
pub style: Style,
pub borders: Borders,
pub border_set: Set<'content>,
pub border_style: Style,
}Expand description
Configuration for a popup.
This struct is used to configure a Popup. It can be created using
Popup::new.
§Example
use ratatui::prelude::*;
use ratatui::symbols::border;
use tui_popup::Popup;
fn render_popup(frame: &mut Frame) {
let popup = Popup::new("Press any key to exit")
.title("tui-popup demo")
.style(Style::new().white().on_blue())
.border_set(border::ROUNDED)
.border_style(Style::new().bold());
frame.render_widget(popup, frame.area());
}Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.body: WThe body of the popup.
title: Line<'content>The title of the popup.
style: StyleThe style to apply to the entire popup.
borders: BordersThe borders of the popup.
border_set: Set<'content>The symbols used to render the border.
border_style: StyleBorder style
Implementations§
Source§impl<'content, W> Popup<'content, W>
impl<'content, W> Popup<'content, W>
Sourcepub fn title(self, value: impl Into<Line<'content>>) -> Popup<'content, W>
pub fn title(self, value: impl Into<Line<'content>>) -> Popup<'content, W>
Sets the title field of this struct.
Sourcepub fn style(self, value: impl Into<Style>) -> Popup<'content, W>
pub fn style(self, value: impl Into<Style>) -> Popup<'content, W>
Sets the style field of this struct.
Sourcepub fn borders(self, value: impl Into<Borders>) -> Popup<'content, W>
pub fn borders(self, value: impl Into<Borders>) -> Popup<'content, W>
Sets the borders field of this struct.
Sourcepub fn border_set(self, value: impl Into<Set<'content>>) -> Popup<'content, W>
pub fn border_set(self, value: impl Into<Set<'content>>) -> Popup<'content, W>
Sets the border_set field of this struct.
Sourcepub fn border_style(self, value: impl Into<Style>) -> Popup<'content, W>
pub fn border_style(self, value: impl Into<Style>) -> Popup<'content, W>
Sets the border_style field of this struct.
Trait Implementations§
Source§impl<W> StatefulWidget for &Popup<'_, W>
Reference stateful render path for a popup body that renders by reference.
impl<W> StatefulWidget for &Popup<'_, W>
Reference stateful render path for a popup body that renders by reference.
Use this when you have long-lived popup data and want to update PopupState without moving the
popup each frame. This requires the body to support rendering by reference.
§Example
let popup = Popup::new(Text::from("Body"));
let popup_ref = &popup;
let mut state = PopupState::default();
popup_ref.render(buffer.area, &mut buffer, &mut state);Source§type State = PopupState
type State = PopupState
Source§impl<W> StatefulWidget for Popup<'_, W>
Owned stateful render path for a popup.
impl<W> StatefulWidget for Popup<'_, W>
Owned stateful render path for a popup.
Use this when you have a PopupState that you want to update across frames and you can pass
the popup by value in the render call.
§Example
let popup = Popup::new("Body");
let mut state = PopupState::default();
popup.render(buffer.area, &mut buffer, &mut state);Source§type State = PopupState
type State = PopupState
Source§impl<W> Widget for &Popup<'_, W>
Reference render path for a popup body that supports rendering by reference.
impl<W> Widget for &Popup<'_, W>
Reference render path for a popup body that supports rendering by reference.
Use this when you want to keep a Popup around and render it by reference. This is helpful
when the body implements Widget for references (such as Text), or when you need to avoid
rebuilding the widget each frame.
§Example
let popup = Popup::new(Text::from("Body"));
let popup_ref = &popup;
popup_ref.render(buffer.area, &mut buffer);Source§impl<W> Widget for Popup<'_, W>
Owned render path for a popup.
impl<W> Widget for Popup<'_, W>
Owned render path for a popup.
Use this when you have an owned Popup value and want to render it by value. This is the
simplest option for new users, and it works well with common bodies like &str or String.
§Example
let popup = Popup::new("Body");
popup.render(buffer.area, &mut buffer);Auto Trait Implementations§
impl<'content, W> Freeze for Popup<'content, W>where
W: Freeze,
impl<'content, W> RefUnwindSafe for Popup<'content, W>where
W: RefUnwindSafe,
impl<'content, W> Send for Popup<'content, W>where
W: Send,
impl<'content, W> Sync for Popup<'content, W>where
W: Sync,
impl<'content, W> Unpin for Popup<'content, W>where
W: Unpin,
impl<'content, W> UnwindSafe for Popup<'content, W>where
W: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more