Skip to content

Configuration

Toastflow resolves config in this order:

  1. Internal defaults (toastflow-core).
  2. Global config passed to createToastflow(...) or createToastStore(...).
  3. Per-toast overrides in show, typed helpers, loading, or update.

Full Option Reference

OptionTypeDefaultNotes
offsetstring"16px"Distance of stack from viewport edge.
gapstring"8px"Gap between toasts in the same stack.
zIndexnumber9999Applied to root container layer.
widthstring"350px"Default toast width.
overflowScrollbooleanfalseEnables stack scroll on overflow. Vue renderer supports it on top positions only.
durationnumber5000Auto-dismiss delay in ms. Infinity or 0 disables scheduling.
maxVisiblenumber5Max visible toasts per position. <= 0 means no cap.
queuebooleanfalseQueue overflowed toasts instead of evicting visible ones.
positionToastPosition"top-right"One of six viewport anchors.
alignment"left" | "right""left"Text/content direction inside toast body.
progressAlignment"left-to-right" | "right-to-left""right-to-left"Progress animation direction.
preventDuplicatesbooleanfalseDe-duplicates by position + type + title + description.
order"newest" | "oldest""newest"Controls insert order and eviction target.
progressBarbooleantrueProgress bar for finite durations.
pauseOnHoverbooleantruePause timer while hovered or touch-held.
pauseStrategy"resume" | "reset""resume"Resume with remaining time or restart full duration.
animationPartial<ToastAnimation>See belowCSS classes for transitions and bump/update effects.
closeButtonbooleantrueShow floating close button.
closeOnClickbooleanfalseDismiss when clicking toast body.
swipeToDismissbooleanfalseAllows dismissing a toast with a right swipe/drag (touch and mouse).
buttonsToastButtonsConfigundefinedInline action buttons config (alignment, layout, spacing).
supportHtmlbooleanfalseAllows HTML in title and description.
showCreatedAtbooleanfalseShows created-at text badge.
createdAtFormatter(createdAt: number) => stringlocale time formatterFormatter for created-at display text.
onMount(ctx) => voidundefinedCalled after toast enters state.
onUnmount(ctx) => voidundefinedCalled after toast is removed from state.
onClick(ctx, event) => voidundefinedCalled when toast body is clicked.
onClose(ctx) => voidundefinedCalled right before leaving phase starts.

Default animation object:

ts
{
  name: "Toastflow__animation",
  bump: "Toastflow__animation-bump",
  clearAll: "Toastflow__animation-clearAll",
  update: "Toastflow__animation-update"
}

Buttons Config

ts
interface ToastButtonsConfig {
  alignment?:
    | "top-left"
    | "top-right"
    | "center-left"
    | "center-right"
    | "bottom-left"
    | "bottom-right";
  layout?: "row" | "column";
  buttons?: ToastButton[];
  gap?: string;
  contentGap?: string;
}

ToastButton supports either label or html, plus optional id, ariaLabel, className, and onClick(ctx, event).

Example Global Config

ts
import { createToastflow } from "vue-toastflow";

app.use(
  createToastflow({
    position: "top-right",
    duration: 5000,
    maxVisible: 4,
    queue: true,
    pauseStrategy: "resume",
    preventDuplicates: true,
    closeButton: true,
    supportHtml: false,
    animation: {
      name: "Toastflow__animation",
    },
  }),
);

Example Per-Toast Overrides

ts
toast.warning({
  title: "Server maintenance",
  position: "bottom-center",
  duration: 15000,
  closeOnClick: true,
  buttons: {
    alignment: "bottom-right",
    buttons: [{ label: "Dismiss" }],
  },
});
  • Runtime shape and lifecycle markers: State
  • Mutating methods and validation rules: Actions