Malevich

Overlays/

Toast

Sonner-style stack manager. Auto-dismiss with hover-pause.

Toast + Notifications

Sonner-inspired stack manager for transient notifications. Per the answered design question recorded with this component: top-stack with auto-dismiss, hover pauses the timer.

Two layers:

When to use

For blocking confirmations, use Dialog. For inline form errors, use the Error element inside a Field-group.

API

import { createNotifications } from "@malevich/components";

const notify = createNotifications({ position: "bottom-right" });

notify.show({
  title: "Saved",
  description: "Your changes were saved.",
  variant: "success",
  duration: 5000,  // ms; 0 = persist until dismissed
});

// Later:
notify.dismissAll();

If a <ol class="notifications"> element already exists with the matching data-position, the runtime reuses it. Otherwise it creates one and appends to <body>.

Variants

Variant Class Default icon
Neutral .toast
Info .toast.-info
Success .toast.-success
Warning .toast.-warning
Danger .toast.-danger

Variants color the left edge and the icon; the rest stays neutral so the message reads clearly against the surface.

Positions

data-position on the container:

Bottom positions stack newest-at-bottom (column-reverse) so the most recent message appears closest to the viewport edge.

Anatomy

Authored (static) toast for tests / docs:

<ol class="notifications" data-position="bottom-right"
    aria-live="polite" aria-label="Notifications">
  <li class="toast -success">
    <span class="toast__icon" aria-hidden="true">✓</span>
    <div class="toast__content">
      <strong class="toast__title">Saved</strong>
      <p class="toast__description">Your changes were saved.</p>
    </div>
    <button class="toast__dismiss" aria-label="Dismiss">×</button>
  </li>
</ol>

Programmatic (typical):

notify.show({ title: "Sent", variant: "success" });
notify.show({ title: "Couldn't save", description: "Try again later.", variant: "danger" });

Tokens used

Component-tier (defined inline on .notifications)

Accessibility

Edge cases

Do

Don't