Toast

A short message that confirms what happened, at the top right. Built on ui-sdk's Toast: call toast() from anywhere, the region announces it, hovering or focusing pauses it, F6 moves focus into it, and Escape or a swipe dismisses it. Place one Toaster near the root.

BetaReady to use. Its API can still change in a minor release; the changelog says when.

import { Toaster, toast } from "@leap-crm/design-system";

Kinds

A white 400 px card: the status badge, a 12/16 title at 450 over a muted description, and an inline close. Errors are announced assertively.

Action and loading

An action renders as an extra-small outline button. A loading toast holds a spinner in the badge's place and stays until it's updated; toast.promise turns it into success or error.

Convert toast

A long job's steps under its title, updated in place with toast.update. Each step's dot turns into the spinner, which holds for a full pass and then turns into a tick that draws itself, at a calm pace; its label changes colour with the mark, never ahead of it. On success the toast closes from its list of steps down to the result card as the steps soften out, then the title and matter number settle in. On failure the step's cross draws, its reason opens beneath it, the title becomes the failure and Retry opens its space.

Icons

The four badges: 28 px circles on their status tint with a 20 px glyph. Warning is a circled !, error a circled ×, so they differ by shape as well as colour.

What the examples share

The imports and the scaffolding the examples above call. The scaffolding lives in this page, not in the library.

import { Button, TextLink, ToastIcon, ToastSteps, toast, type ToastStep } from "@leap-crm/design-system";

const wait = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));

const stepLabels = [
  "Preparing the matter",
  "Resolving LEAP cards",
  "Creating the matter in LEAP",
  "Linking the opportunity",
] as const;

const statusAt = (index: number, active: number): ToastStep["status"] => {
  if (index < active) return "done";
  if (index === active) return "active";
  return "pending";
};

const stepsAt = (active: number): ToastStep[] =>
  stepLabels.map((label, index) => ({
    label,
    status: statusAt(index, active),
  }));

async function convert(fail: boolean) {
  const id = toast.loading({
    title: "Converting to matter",
    description: <ToastSteps steps={stepsAt(0)} />,
  });
  for (const active of [1, 2]) {
    await wait(900);
    toast.update(id, { description: <ToastSteps steps={stepsAt(active)} /> });
  }
  await wait(900);
  if (fail) {
    toast.update(id, {
      type: "error",
      title: "Conversion failed",
      duration: Infinity,
      action: { label: "Retry", onAction: () => convert(false) },
      description: (
        <ToastSteps
          steps={[
            ...stepsAt(2).slice(0, 2),
            {
              label: stepLabels[2],
              status: "failed",
              note: "LEAP didn’t accept the matter type’s layout.",
            },
            { label: stepLabels[3], status: "pending" },
          ]}
        />
      ),
    });
    return;
  }
  toast.update(id, {
    type: "success",
    title: "Matter created successfully",
    duration: 5000,
    description: (
      <TextLink size="sm" href="/toast">
        CRM/1042
      </TextLink>
    ),
  });
}

function Kinds() {
  return (
    <div className="flex flex-wrap gap-2">
      <Button
        intent="outline"
        onClick={() =>
          toast.success({
            title: "Contact created",
            description: "Jane Citizen was added to your contacts.",
          })
        }
      >
        Success
      </Button>
      <Button
        intent="outline"
        onClick={() =>
          toast.info({
            title: "Note saved to Agency Purchase",
            description: "It shows on the opportunity's timeline.",
          })
        }
      >
        Info
      </Button>
      <Button
        intent="outline"
        onClick={() =>
          toast.warning({
            title: "Email sent without the attachment",
            description: "The file was larger than 25 MB.",
          })
        }
      >
        Warning
      </Button>
      <Button
        intent="outline"
        onClick={() =>
          toast.error({
            title: "Couldn’t save the contact",
            description: "Please check your connection and try again.",
          })
        }
      >
        Error
      </Button>
    </div>
  );
}

Best practices

When to use it, and the rules that apply in particular places.

GuidancePractice
DoUse it to confirm something a person just did, like adding a contact or logging an email, with a title that says what happened.
DoPlace one Toaster near the root and call toast() from anywhere.
DoGive a reversible change an action, like Undo after hiding a contact from search.
DoUse toast.promise for a job that takes a moment, and ToastSteps updated with toast.update for a long job with stages, like converting an opportunity to a matter.
Don'tUse a toast for something a person must act on later, like a mailbox that isn't connected. It leaves on its own; use Alert in the page.
Don'tRely on colour alone to tell a warning from an error. Say which it is in the title, and write an error's description as what to do, like "Please check your connection and try again."

Props

toast(), toast.success, .info, .warning, .error, .loading and .promise take a title or { title, description, action, cancel, duration, id, dismissible }; toast.update and toast.dismiss change one by id. Toaster takes side, align, maxVisible, expanded and shortcut.

Toaster

PropTypeDefaultDescription
classNamestring—Classes added to the root element, merged with its own. Tokens only.
sideunknown"top"Which side it opens on. It flips to the other when there isn't room.
alignunknown"end"How it lines up along that side: start, center or end.

ToastIcon

PropTypeDefaultDescription
kind *"success" | "info" | "warning" | "error"—success, info, warning or error: the glyph and its badge colour.
classNamestring—Classes added to the root element, merged with its own. Tokens only.

ToastSteps

PropTypeDefaultDescription
steps *unknown—The job's steps in order: each a label, a status and an optional note.

Keyboard

The keys it answers to. Tab moves between components, arrows move within them.

KeysWhat they do
F6Moves focus to the newest toast, and again back where it was.
EscapeCloses the focused toast, unless it can't be dismissed.
TabPast the last toast, goes back where F6 came from.