Fetch Cursor

A small badge that trails the pointer while something the person clicked is fetching: a spinner that turns into a drawn tick or cross when it settles. It shows the wait where they're looking, a moment behind the pointer. With reduced motion nothing follows the pointer; the cursor becomes the system's progress cursor.

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

import { FetchCursor } from "@leap-crm/design-system";

Fetching after a click

Press a button and move the pointer: the badge follows it while the fetch runs (1.2 s here), then draws its result and leaves. Set state to busy when the fetch starts, done or error when it settles, and idle to put it away. One per page is enough; it renders into the body.

What the examples share

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

import { useState } from "react";

import { Button, FetchCursor, RefreshCwIcon, type StatusMarkState } from "@leap-crm/design-system";

const wait = (ms: number) =>
  new Promise<void>(resolve => {
    setTimeout(resolve, ms);
  });

const labels: Partial<Record<StatusMarkState, string>> = {
  busy: "Refreshing contacts",
  done: "Contacts refreshed",
  error: "Couldn't refresh contacts",
};

function Fetching({ outcome }: { outcome: "done" | "error" }) {
  const [state, setState] = useState<StatusMarkState>("idle");
  const fetchContacts = async () => {
    setState("busy");
    await wait(1200);
    setState(outcome);
    setTimeout(() => setState("idle"), 1400);
  };
  return (
    <>
      <Button
        intent="outline"
        icon={<RefreshCwIcon />}
        onClick={() => {
          void fetchContacts();
        }}
      >
        {outcome === "done" ? "Refresh contacts" : "Refresh (fails)"}
      </Button>
      <FetchCursor state={state} label={labels[state]} />
    </>
  );
}

Best practices

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

GuidancePractice
DoUse it while something the person clicked is fetching, like pressing a contact and waiting for its workspace, so the wait shows where they're looking.
DoSet state to busy when the fetch starts, done or error when it settles, then idle to put it away.
DoRender one per page. It draws into the body, so one copy serves every click on the page.
DoGive it a label, like "Loading contacts", unless the page already announces the fetch. Without one it is decorative.
Don'tUse it for a wait the person didn't start, like a background sync. Show a Spinner or Skeleton where the content will appear.
Don'tMake anything else follow the pointer, like a contact preview. A preview anchors to what it's about, in a HoverCard.

Props

PropTypeDefaultDescription
state *"idle" | "busy" | "done" | "error"—busy while the fetch runs; done or error once it settles, then idle to put it away. Idle shows nothing.
labelstring—What screen readers hear while it shows, like "Loading contacts". Leave it out when the page already announces the fetch.