@usevyre/react @usevyre/vue

Toast

Imperative notification system. Call toast() from anywhere in your app — no prop drilling required. Messages stack in the top-right corner and auto-dismiss after 4 seconds.


Setup

React: wrap your app root with ToastProvider once. Vue: place ToastViewport once in your app root or layout component.

// 1. Wrap your app root once
import { ToastProvider } from "@usevyre/react";

<ToastProvider>
  <App />
</ToastProvider>

Usage

Call useToast() inside any component to get the toast() function.

import { useToast } from "@usevyre/react";

function SaveButton() {
  const { toast } = useToast();
  return (
    <Button onClick={() => toast({ title: "Saved!", variant: "success" })}>
      Save
    </Button>
  );
}

Variants & options

toast({ title: "Saved",            variant: "success" });
toast({ title: "Heads up",         variant: "warning" });
toast({ title: "Something failed", variant: "danger" });
toast({ title: "FYI",              variant: "default" });

// With description
toast({
  title: "Deployment complete",
  description: "v1.2.0 is now live.",
  variant: "success",
});

// Stays until dismissed
toast({ title: "Processing…", duration: Infinity });

toast() options

Props

Prop Type Default Description
title string Primary message shown in bold.
description string Secondary detail text below the title.
variant "default" | "success" | "warning" | "danger" "default" Colour style.
duration number 4000 Auto-dismiss delay in ms. Pass Infinity to keep until dismissed.