ilokesto

API Reference

Public facade, components, hooks, runtime, and exported types.

API Reference

@ilokesto/toast exports named values only.

Values

toast

The facade surface:

toast(message, options?)
toast.success(message, options?)
toast.error(message, options?)
toast.loading(message, options?)
toast.custom(message, options?)
toast.promise(promiseOrFactory, messages, options?)
toast.dismiss(id?, toasterId?)
toast.remove(id?, toasterId?)

Important behavior:

  • toast.loading() forces infinite duration
  • toast.promise() accepts either Promise<T> or () => Promise<T>
  • dismiss() is soft close
  • remove() is immediate

Toaster

The main rendering component for one runtime.

See Toaster for full prop details.

ToastBar

The default row renderer primitive.

See ToastBar for details.

ToastIcon

The built-in icon renderer used by the default row.

useToaster()

Headless hook returning:

{
  toasts,
  handlers: {
    updateHeight,
    startPause,
    endPause,
    calculateOffset,
  }
}

useToastItems(runtime)

Low-level external-store subscription for visible toast items of a runtime.

createToastRuntime(toasterId)

Creates one toast runtime instance.

Types

The root package also exports these public types:

  • ToastBarProps
  • Renderable
  • ToastId
  • ToasterId
  • ToastType
  • ToastStatus
  • ToastPosition
  • ToastTransport
  • ToastItem
  • ToastState
  • ToastOptions
  • DefaultToastOptions
  • IconTheme
  • ToastStoreApi
  • ToastFacade
  • ToasterProps
  • UseToasterResult
  • ToastRowHelpers
  • ToastRuntimeApi
  • PromiseToastMessages

On this page