Skip to main content

alert

Function alert 

Source
pub fn alert<S>(variant: AlertVariant) -> El<S>
Expand description

A bordered box for a message, holding an alert_title and an alert_description.

Both roles are live regions. A screen reader reads a role="alert" box when a patch puts it on the page, as for a server error. A role="status" box is read when its text changes, and some screen readers skip one that arrives with its text already in it, so keep a status box on the page and change its text with bind_text.

use hypersig::Signals;
use hypersig_ui::{AlertVariant, alert, alert_description, alert_title};
use serde::{Deserialize, Serialize};

#[derive(Signals, Serialize, Deserialize)]
struct App {}

let failed = alert::<App>(AlertVariant::Destructive)
    .child(alert_title().text("Payment failed"))
    .child(alert_description().text("The card was declined."));
assert!(failed.render().contains(r#"role="alert""#));