Zephora UI

Overlay

Toast

Transient notification stack. Wrap the app in ToastProvider and fire toasts imperatively with useToast(); danger toasts announce assertively, others politely. Hovering pauses the auto-dismiss timer.

Import

import { ToastProvider, useToast, Toast } from "@zephora/react";

Examples

Firing toasts

`useToast()` returns `toast(options)` which shows a toast and returns its id. `duration: null` keeps a toast until closed.

Action and dismiss

Toasts can carry one action; `dismiss(id)` removes a toast programmatically.

Promise flow

`toast.promise(promise, { loading, success, error })` shows a sticky loading toast, then updates the SAME toast when the promise settles. `success`/`error` accept content or a function of the result. For manual control use `update(id, options)` and `dismissAll()`.

Standalone Toast card

The presentational `<Toast>` can be rendered inline — ToastProvider uses it internally.

Build passed
All 214 tests green.

API

ToastProvider props

PropTypeDefaultDescription
position"top-start" | "top" | "top-end" | "bottom-start" | "bottom" | "bottom-end""bottom-end"Viewport corner where toasts stack.
maxToastsnumberMaximum number of toasts visible at once; further toasts queue (FIFO) and appear as soon as a slot frees up.
unstyledbooleanfalseHeadless mode — skips Zephora styling.

useToast() props

PropTypeDefaultDescription
toast(options)(options: ToastOptions) => stringShows a toast and returns its id. Also exposes toast.promise().
update(id, options)(id: string, options: Partial<ToastOptions>) => voidRe-renders an existing toast in place; restarts the timer if duration is provided.
dismiss(id)(id: string) => voidRemoves the toast with the given id (plays the exit animation).
dismissAll()() => voidRemoves every visible toast and clears the pending queue.
promise(promise, options)<T>(promise: Promise<T>, options: { loading, success, error }) => Promise<T>Shows a sticky loading toast, then updates the same toast to a success/error message when the promise settles. Returns the promise.

useToast() → toast(options) props

PropTypeDefaultDescription
title *ReactNodeMain line of the toast.
descriptionReactNodeSupporting text under the title.
status"info" | "success" | "warning" | "danger""info"Semantic tone; danger announces assertively.
durationnumber | null5000Auto-dismiss delay in ms; null keeps the toast until closed.
action{ label: string; onClick: () => void }Single action button rendered next to the content.
iconReactNode | nullLeading icon. Defaults to the built-in status icon; pass null to render no icon at all.
positionToastPositionViewport corner for this toast; falls back to the provider position.

Toast (standalone) props

PropTypeDefaultDescription
title *ReactNodeMain line of the toast.
descriptionReactNodeSupporting text under the title.
status"info" | "success" | "warning" | "danger""info"Semantic tone.
action{ label: string; onClick: () => void }Single action button.
durationnumber | nullnullAuto-dismiss delay in ms (requires onClose); null disables the timer. The timer pauses on hover.
onClose() => voidRenders the close button and is called on close / when the timer fires.
unstyledbooleanfalseHeadless mode.