glaze/oat/toast

Oat documentation: https://oat.ink/components/toast/

Programmatic toast notifications.

Anatomy

Choose a Variant, configure Options, and call toast to trigger a notification from application code.

Recipes

import glaze/oat/toast

let options =
  toast.default_options(toast.Success)
  |> toast.with_placement(toast.BottomRight)
  |> toast.with_duration_ms(3000)

toast.dispatch("Saved", "Your changes were stored.", options)

Types

Configuration for when launching a toast.

pub type Options {
  Options(
    variant: Variant,
    placement: Placement,
    duration_ms: Int,
  )
}

Constructors

Screen placement for a toast.

pub type Placement {
  TopRight
  TopLeft
  TopCenter
  BottomLeft
  BottomRight
  BottomCenter
}

Constructors

  • TopRight
  • TopLeft
  • TopCenter
  • BottomLeft
  • BottomRight
  • BottomCenter

Toast visual style.

pub type Variant {
  Info
  Success
  Danger
  Warning
}

Constructors

  • Info
  • Success
  • Danger
  • Warning

Values

pub fn default_options(variant: Variant) -> Options

Create default options for a given variant.

Defaults are top-right placement and 4000 milliseconds duration.

pub fn dispatch(
  title: String,
  description: String,
  options: Options,
) -> Nil

Trigger a toast notification.

Available in the Browser.

pub fn options_to_json(options: Options) -> json.Json
pub fn placement_to_json(placement: Placement) -> json.Json
pub fn variant_to_json(variant: Variant) -> json.Json
pub fn with_duration(
  options: Options,
  duration_ms: Int,
) -> Options
pub fn with_placement(
  options: Options,
  placement: Placement,
) -> Options
Search Document