iced_dialog

Crates.ioiced_dialog
lib.rsiced_dialog
version0.14.0
created_at2025-07-04 20:58:59.637183+00
updated_at2025-12-08 14:46:43.05809+00
descriptionA custom dialog widget for `iced`
homepagehttps://sr.ht/~pml68/iced_dialog
repositoryhttps://git.sr.ht/~pml68/iced_dialog
max_upload_size
id1738465
size129,109
Polesznyák Márk László (pml68)

documentation

README

iced_dialog

builds.sr.ht status   docs

Custom dialog for iced

It's mostly the dialog from @frgp42's Fluent Iced Gallery, but made into a "widget"

Example

use iced::{
    Element, Task,
    widget::{button, center, column, text},
};
use iced_dialog::dialog;

#[derive(Default)]
struct State {
    is_open: bool,
    action_text: &'static str,
}

#[derive(Debug, Clone)]
enum Message {
    OpenDialog,
    Saved,
    Cancelled,
}

fn main() -> iced::Result {
    iced::run(State::update, State::view)
}

impl State {
    fn update(&mut self, message: Message) -> Task<Message> {
        match message {
            Message::OpenDialog => self.is_open = true,
            Message::Saved => {
                self.action_text = "User saved their work";
                self.is_open = false;
            }
            Message::Cancelled => {
                self.action_text = "User cancelled the dialog";
                self.is_open = false;
            }
        }
        Task::none()
    }

    fn view(&self) -> Element<'_, Message> {
        let base = center(
            column![
                text(self.action_text),
                button("Open Dialog").on_press(Message::OpenDialog)
            ]
            .spacing(14.0),
        );

        let dialog_content = text("Do you want to save?");

        dialog(self.is_open, base, dialog_content)
            .title("Save")
            .push_button(iced_dialog::button("Save work", Message::Saved))
            .push_button(iced_dialog::button("Cancel", Message::Cancelled))
            .width(350)
            .height(234)
            .on_press(Message::Cancelled)
            .into()
    }
}

You can also run the above example:

cargo run -p example
Commit count: 0

cargo fmt