NudgeUI
DocsAPI Reference

API Reference

Complete options and methods reference for Nudge UI.

toast methods

MethodSignatureDescription
toast.show()show(message, options?): stringShow a toast. Returns toast ID.
toast.success()success(message, options?): stringShow a success toast.
toast.error()error(message, options?): stringShow an error toast.
toast.warning()warning(message, options?): stringShow a warning toast.
toast.info()info(message, options?): stringShow an info toast.
toast.loading()loading(message, options?): stringShow a loading spinner toast.
toast.dismiss()dismiss(id: string): voidRemove a toast by ID.
toast.clearAll()clearAll(): voidRemove all toasts immediately.
toast.update()update(id, updates): voidUpdate an existing toast.

ToastOptions

OptionTypeDefaultDescription
type"default" | "success" | "error" | "warning" | "info" | "loading" | "custom""default"Visual type of the toast.
position"top-right" | "top-left" | "top-center" | "bottom-right" | "bottom-left" | "bottom-center""top-right"Screen position of the toast stack.
autoClosebooleantrueAuto-dismiss after duration.
durationnumber (ms)4000Time before auto-dismiss. Requires autoClose: true.
allowHtmlbooleanfalseRender message as raw HTML. ⚠️ Sanitize first.
titlestringundefinedOptional bold title above the message.
onClose(toast: ToastItem) => voidundefinedCallback fired when the toast is removed.
classNamestringundefinedAdditional CSS class(es) on the toast element.
twClassstringundefinedAdditional Tailwind utility class string.

ToastItem (resolved)

FieldTypeDescription
idstringUnique toast identifier.
messagestringThe toast message text (or HTML if allowHtml).
typeToastTypeThe resolved toast type.
positionToastPositionThe resolved position.
autoClosebooleanWhether auto-dismiss is active.
durationnumberAuto-dismiss duration in ms.
allowHtmlbooleanWhether message is rendered as HTML.
titlestringOptional title text.
createdAtnumberUnix timestamp when the toast was created (Date.now()).
exitingbooleanInternal - true when the exit animation is playing.

ToasterCore (class)

MethodDescription
addToast(message, options?)Add a toast. Returns ID.
updateToast(id, updates)Update an existing toast's fields.
removeToast(id)Begin exit animation and remove after 280ms.
clearAll()Immediately remove all toasts.
subscribe(listener)Register a listener fn(toasts[]) - returns unsubscribe fn.
getToasts()Returns current toasts snapshot array.