Menu

UI

Zero-dependency UI primitives — auto-injected CSS, role="dialog", focus, ESC/backdrop close, reference-counted loading.

toastmodalloading

toast

js
F.toast("Saved!", "success"); // "info" | "success" | "error" | "warn"
F.toast("Hello", { type: "info", duration: 3000 });
const el = F.toast("Click to dismiss", "info");
el.addEventListener("click", () => el.remove()); // built-in

Container .flash-toast-container is created once; stacking is automatic. Click dismisses early.

modal / alert / confirm

js
// low-level
const value = await F.modal({
  title: "Delete?",
  message: "This cannot be undone.",
  actions: [
    { label: "Cancel", value: null, variant: "ghost" },
    { label: "Delete", value: true, variant: "primary" }
  ],
  closeOnBackdrop: true
});

// sugar
await F.alert("Saved!", "Done"); // → Promise<true|null>
const ok = await F.confirm("Delete item?", "Confirm"); // → Promise<boolean|null>

Focus goes to the first action, Esc resolves null, backdrop click resolves null when enabled.

loading

js
F.loading(true);   // shows overlay — reference counted
await doWork();
F.loading(false);  // hides when count reaches 0

F.loading(true); F.loading(true); F.loading(false); // still visible until second false
ESM: import { toast, modal, loading } from "flash.js/ui"

Live demo

—

Utilities →

⌕