fin1te/dsv1.0.0
  1. ds
  2. Components
  3. Toast

Toast

Short confirmations at the bottom of the screen.

Saved to file
Code
<div class="toast" role="status">Copied as topo text</div>

Toasts confirm something that already happened: copied, saved, added. Ink on paper, bottom centre, gone after 1.6 seconds. They never hold an action you need.

let el, t;
export function toast(msg) {
  el ??= Object.assign(document.body.appendChild(document.createElement('div')), { className: 'toast', role: 'status' });
  el.textContent = msg;
  requestAnimationFrame(() => el.classList.add('show'));
  clearTimeout(t);
  t = setTimeout(() => el.classList.remove('show'), 1600);
}
ClassOnWhat it does
.toastdiv[role=status]Fixed at the bottom centre, hidden until .show.
.show.toastVisible: fades and rises in.
.inline.toastStatic, for documentation and previews.