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

Opaque Alert type with builder pattern

pub opaque type Alert(msg)

The size of the alert to display

pub type AlertSize {
  Normal
  Compact
}

Constructors

  • Normal
  • Compact

The type of alert to display

pub type AlertType {
  Success
  Info
  Warning
  Danger
}

Constructors

  • Success
  • Info
  • Warning
  • Danger

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

pub fn with_size(
  alert: Alert(msg),
  size: AlertSize,
) -> Alert(msg)

Set the size of the alert

pub fn with_type(
  alert: Alert(msg),
  alert_type: AlertType,
) -> Alert(msg)

Set the type of alert

Search Document