lustre/prefab/alert
Alert component for lustre_prefab.
A simple alert component that can be used to display messages to the user. See https://clarity.design/documentation/alert
Types
The size of the alert to display
pub type AlertSize {
Normal
Compact
}
Constructors
-
Normal -
Compact
Values
pub fn new(message: String) -> Alert(msg)
Create a new alert with the given message and default settings
Example
alert.new("Operation completed successfully")
|> alert.with_type(alert.Success)
|> alert.with_dismiss(OnDismiss)
|> alert.view([])
pub fn view(
alert: Alert(msg),
extra_attrs: List(@internal Attribute(@internal Aligned, msg)),
) -> stylish.Element(msg)
Display the alert
Example
alert.new("Operation completed!")
|> alert.with_type(alert.Success)
|> alert.view([])
pub fn with_dismiss(
alert: Alert(msg),
on_close: msg,
) -> Alert(msg)
Set a dismiss button with the given message
pub fn with_dismiss_text(
alert: Alert(msg),
dismiss_text: String,
) -> Alert(msg)
Set custom text for the dismiss button