1. Documentation
  2. Feedback
  3. Toast
ReadmenpmGitHub
  • Introduction
  • Installation
  • Theming
  • Icons
  • Accordion
  • Card
  • Scroll Area
  • Separator
  • Sidebar
  • Field
  • Label
  • Input
  • Textarea
  • Number Field
  • OTP Field
  • Select
  • Combobox
  • Checkbox
  • Radio
  • Switch
  • Slider
  • Toggle
  • Calendar
  • Date Picker
  • File Upload
  • Button
  • Copy Button
  • Dropdown
  • Command
  • Tabs
  • Breadcrumb
  • Pagination
  • Tree
  • Table
  • Data Table
  • Stat
  • Timeline
  • Avatar
  • Status Bar
  • Badge
  • Meter
  • Empty
  • Skeleton
  • Spinner
  • Toast
  • Dialog
  • Sheet
  • Popover
  • Tooltip
  • Text
  • Kbd
  • Code Block
  • Utilities
  • Design rules

Toast

Mount a Toaster once; everything else is a plain function call from anywhere.

Loading documentation…

Spinner< PreviousDialogNext >

Powered by heyo

On this page

UsageTonesPromisesUpdating and closingPlacementPropertiestoast(title, options)The toast namespaceToaster
toast("Settings saved");toast.success("Deployed", { description: "acme-api is live" });toast.error("Deploy failed", {description: "Build step exited with code 1.",timeout: 0,});await toast.promise(deploy(), {loading: "Deploying…",success: "Deployed",error: "Deploy failed",});

Mount <Toaster /> once, near the root. Everything after that is a plain function call from anywhere in the application — no hook, no context, no provider in your component tree, and nothing to thread through props.

Usage

tsx
import { Toaster, toast } from "@heyo-sh/heyo-ui";// once, near the root<Toaster />;// anywheretoast.success("Deployed", { description: "acme-api is live" });

Tones

tsx
toast("Settings saved");toast.success("Deployed");toast.error("Deploy failed");toast.warning("Quota almost reached");toast.info("A new version is available");

timeout: 0 keeps a toast up until it is closed — the right choice for an error the reader has to act on, and the wrong one for everything else.

Promises

toast.promise takes one toast through all three states and resolves to the promise's own value, so it drops into an existing call without restructuring it.

tsx
await toast.promise(deploy(), {  loading: "Deploying…",  success: "Deployed",  error: "Deploy failed",});

Updating and closing

Every call returns an id.

tsx
const id = toast("Uploading…", { timeout: 0 });toast.update(id, { title: "Uploaded", description: "3 files" });toast.close(id);toast.close(); // everything

Placement

The Toaster owns the corner, the stack limit and the default timeout. Bottom-right is the default because it is the furthest corner from where the work is happening.

tsx
<Toaster position="bottom-right" limit={3} timeout={5000} />
A toast is not an error page

Anything the reader must answer belongs in a Dialog; anything they must keep reading belongs on the page. A toast is for something that already happened.

Properties

toast(title, options)

titleReactNoderequired

The headline. Keep it to one line.

descriptionReactNodeoptional

A second line — what exactly happened, or what to do next.

timeoutnumberoptional

Milliseconds before auto-dismiss. 0 keeps it until closed.

actionPropsRecord<string, unknown>optional

Props for the action slot, passed through to Base UI.

The toast namespace

toast.success / error / warning / info(title, options) => stringoptional

The toned variants. Each returns the new toast's id.

toast.promise(promise, { loading, success, error }) => Promiseoptional

Drives one toast through pending, fulfilled and rejected, and resolves to the promise's value.

toast.update(id, updates) => voidoptional

Changes a toast in place. updates may be a function of the previous toast.

toast.close(id?) => voidoptional

Closes one toast, or all of them.

toast.managerToastManageroptional

The raw Base UI manager, for anything the shorthands do not cover.

Toaster

position"bottom-right" | "bottom-left" | "top-right" | "top-left"optional

The corner the stack lives in. It defaults to bottom-right.

limitnumberoptional

How many stay visible before the oldest is dropped.

timeoutnumberoptional

The default auto-dismiss, in milliseconds.