Toaster

Stacks and positions a list of toasts you control.

Render-driven toaster: callers own the toast array and remove items in onDismiss.

Toaster rendered by Tarve Toaster rendered by Tarve
Native render. The live version loads when this comes into view.

Import

import { Toaster } from "@tarve/core";

Usage

Toaster.tsx
import { Button, Column, Toaster, theme, type ToastItem } from "@tarve/core";

let toasts: ToastItem[] = [];

<Column
  align="center"
  style={{ position: "relative", width: 440, height: 240, padding: { top: 24 }, radius: 12, borderWidth: 1, borderColor: theme.colors.border }}
>
  <Button
    onClick={() => {
      toasts = [...toasts.slice(-1), { id: String(Date.now()), title: "Exported", description: "report.pdf is ready." }];
    }}
  >
    Export
  </Button>
  <Toaster
    toasts={toasts}
    position="bottom-right"
    onDismiss={(id) => {
      toasts = toasts.filter((toast) => toast.id !== id);
    }}
  />
</Column>

Props

PropTypeDefault
toasts required ToastItem[]—
onDismiss (id: string) => void—
position ToasterPosition"bottom-right"

Common props

Shared by every component. See descriptions →

childrenclassclassNamehighlightidkeymotionFromonHighlightonPasteonPointerLeaveonPointerMoveonSizeonTransitionEndrovingGroupstyle

Types

ToastItem
interface ToastItem {
  id: string;
  title: string;
  description?: string;
  variant?: ToastVariant;
  action?: ToastAction;
}
ToasterPosition
type ToasterPosition = "top-left" | "top-right" | "bottom-left" | "bottom-right";