Crate yew_alert

Source
Expand description

§Yew Alert - Documentation

Welcome to the official Yew Alert library documentation. This library provides a flexible and customizable alert component for your Yew applications.

§Usage

To use the Yew Alert library, add the following dependency to your Cargo.toml file:

cargo add yew-alert

To integrate the library into your Yew application, you can use the Alert component. Here’s a simple example of how to use it:

use yew::prelude::*;
use yew_alert::Alert;

// Your Yew component structure here...

#[function_component]
pub fn MyComponent() -> Html {
    // Your component logic here...
    let show_alert = use_state(|| true);

    html! {
        <div>
            <button onclick=/* Your callback function here to trigger the alert */>{"Show Alert"}</button>
            <Alert
                message="This is a sample alert message."
                show_alert={show_alert} // Use your state or logic to control visibility
                on_confirm=Callback::from(/* Your confirm callback function here */)
                on_cancel=Callback::from(/* Your cancel callback function here */)
            />
        </div>
    }
}

For more detailed information, check the examples provided in the library.

§Configuration

Yew Alert allows you to customize various aspects of the alert component through the AlertProps structure. You can adjust properties such as message content, button text, styling, and more. Refer to the AlertProps documentation for detailed configuration options.

use yew_alert::{AlertProps, Alert};

let alert_props = AlertProps {
    message: "Custom alert message",
    // Add other properties as needed...
    // ...
};

let alert_component = html! {
    <Alert ..alert_props />
};

§Contribution and Support

If you encounter any issues or have suggestions for improvements, feel free to contribute to the GitHub repository. We appreciate your feedback and involvement in making Yew Alert better!

§Acknowledgments

Special thanks to the Yew community and contributors for such an amazing framework.

Structs§