glaze/basecoat/toast

Basecoat documentation: https://basecoatui.com/components/toast/

Programmatic toast notifications.

Note: This component requires JavaScript from Basecoat.

Anatomy

Recipes

import glaze/basecoat/toast
import lustre/element/html

fn success_toast_markup() {
  toast.toast([toast.success()], [
    toast.title([], [html.text("Success")]),
    toast.description([], [html.text("Your changes have been saved.")]),
  ])
}
fn show_toast_script() {
  toast.show(toast.Config(toast.Success, "Success", "Saved!", None, None))
}

References

Types

Optional toast action button.

pub type Action {
  Action(label: String, onclick: option.Option(String))
}

Constructors

Optional toast cancel button.

pub type Cancel {
  Cancel(
    label: option.Option(String),
    onclick: option.Option(String),
  )
}

Constructors

Toast category (visual style).

pub type Category {
  Success
  Info
  Warning
  Error
}

Constructors

  • Success
  • Info
  • Warning
  • Error

Configuration used by show.

pub type Config {
  Config(
    category: Category,
    title: String,
    description: String,
    action: option.Option(Action),
    cancel: option.Option(Cancel),
  )
}

Constructors

Values

pub fn action_button(
  label: String,
  attrs: List(attribute.Attribute(msg)),
) -> element.Element(msg)
pub fn cancel_button(
  label: String,
  attrs: List(attribute.Attribute(msg)),
) -> element.Element(msg)
pub fn content(
  attrs: List(attribute.Attribute(msg)),
  children: List(element.Element(msg)),
) -> element.Element(msg)
pub fn description(
  attrs: List(attribute.Attribute(msg)),
  children: List(element.Element(msg)),
) -> element.Element(msg)
pub fn duration(ms: Int) -> attribute.Attribute(msg)
pub fn error() -> attribute.Attribute(msg)
pub fn error_toast(title: String, description: String) -> String
pub fn footer(
  attrs: List(attribute.Attribute(msg)),
  children: List(element.Element(msg)),
) -> element.Element(msg)
pub fn info() -> attribute.Attribute(msg)
pub fn show(config: Config) -> String
pub fn show_simple(category: Category, title: String) -> String
pub fn success() -> attribute.Attribute(msg)
pub fn success_toast(
  title: String,
  description: String,
) -> String
pub fn title(
  attrs: List(attribute.Attribute(msg)),
  children: List(element.Element(msg)),
) -> element.Element(msg)
pub fn toast(
  attrs: List(attribute.Attribute(msg)),
  children: List(element.Element(msg)),
) -> element.Element(msg)
pub fn toaster(
  attrs: List(attribute.Attribute(msg)),
) -> element.Element(msg)
pub fn toaster_aligned(
  align: String,
  attrs: List(attribute.Attribute(msg)),
) -> element.Element(msg)
pub fn warning() -> attribute.Attribute(msg)
Search Document