toast

look

A short line after an action, in a tone, with an optional undo.

Drawn

Archived 3 orders

The sample

crates/blocks/src/kind/core/toast.rs:16–26

pub(super) fn sample() -> Vec<Block> {
    let ids = serde_json::Value::from(vec!["o-4821", "o-4822", "o-4825"]);
    let undo = Undo {
        action: "unarchive".into(),
        values: Some([("ids".to_string(), ids)].into_iter().collect()),
        ..Undo::default()
    };
    vec![Block::Toast(Box::new(
        Toast::new("Archived 3 orders").id("archived").tone(Tone::Ok).undo(undo),
    ))]
}
{
  "blocks": [
    {
      "fallback": {
        "title": "Archived 3 orders"
      },
      "id": "archived",
      "title": "Archived 3 orders",
      "tone": "ok",
      "type": "toast",
      "undo": {
        "action": "unarchive",
        "values": {
          "ids": [
            "o-4821",
            "o-4822",
            "o-4825"
          ]
        }
      }
    }
  ],
  "fallback": {
    "title": "screen"
  },
  "id": "toast",
  "type": "screen"
}

Its fallback

What a renderer without toast draws: a row from the fallback the block carries.
Archived 3 orders

Style hooks

.b-toastthe block
[data-block=toast]every block of the kind
[data-id=archived]this one block
Every page here is a blocks Screen, written by site::page: no hand-written HTML. Source: https://github.com/jirathip-dev/blocks