Toast

Organism

Notification system with success/warning/error/info/loading variants. Hover-to-freeze, progress bar, title, actions, and promise support.

Success

Preview

File uploaded

report.pdf has been uploaded successfully.

Code
<%- include('modules/ui/Toast', {
  variant: 'success',
  title: 'File uploaded',
  message: 'report.pdf has been uploaded successfully.'
}) %>

Error

Preview

Upload failed

The file exceeds the 10 MB size limit.

Code
<%- include('modules/ui/Toast', {
  variant: 'error',
  title: 'Upload failed',
  message: 'The file exceeds the 10 MB size limit.',
  actionLabel: 'Try again'
}) %>

Warning

Preview

Session expires in 5 minutes.

Code
<%- include('modules/ui/Toast', {
  variant: 'warning',
  message: 'Session expires in 5 minutes.'
}) %>

Info

Preview

New update

Version 2.4 is available. Refresh to apply.

Code
<%- include('modules/ui/Toast', {
  variant: 'info',
  title: 'New update',
  message: 'Version 2.4 is available. Refresh to apply.'
}) %>

Loading

Preview

Saving your changes…

Code
<%- include('modules/ui/Toast', {
  variant: 'loading',
  message: 'Saving your changes…',
  persistent: true
}) %>

toast.promise() API

Preview

Kullanıcı yükleniyor…

Code
<%# Mount once — store.js exposes window.toast() %>
<%- include('modules/ui/Toast/scripts/store.js') %>

<script>
  // Same surface as the NextJS `toast.promise()` — drives one toast
  // through loading → success | error in a single call.
  window.toast.promise(
    fetch('/api/user').then(function (r) { return r.json(); }),
    {
      loading: 'Kullanıcı yükleniyor…',
      success: function (u) { return u.name + ' (#' + u.id + ') yüklendi.'; },
      error:   function (e) { return 'Hata: ' + e.message; },
    }
  );

  // String shortcuts for success/error are also accepted.
  window.toast.promise(saveSettings(), {
    loading: 'Kaydediliyor…',
    success: 'Tamamlandı!',
    error:   'Kaydetme başarısız oldu.',
  });
</script>
Source modules/ui/Toast/Toast.ejs