Skip to main content
Version: 1.0.0

API Options

Contract details for configuration and option objects used by hosts/controllers.

ToastHostConfig Contract

ToastHostConfig is used by ToastProvider.defaultHostConfig and ToastHost.config.

interactionMode is selected at host root props (ToastHost / ToastViewport), not inside config.

ToastHostProps Contract

NameTypeRequiredDefaultDescriptionAllowed options/values
hostIdstringnoprovider default host idHost identity.any string
interactionModeToastInteractionModeno"deck"Host interaction model. Controls whether classic-only or deck-only config fields are valid.classic, deck
configToastHostConfigno{}Host config object for the selected interaction mode.object
classNamestringnononeHost container class name fallback.any string
styleStyleProp<ViewStyle>nononeHost container style fallback.any React Native view style
controllerRefRef<ToastController | null>nononeImperative controller ref for boundary usage.ref
useRNScreensOverlaybooleannononeEnables RN Screens FullWindowOverlay at host level.true, false
rnScreensOverlayViewStyleStyleProp<ViewStyle>nononeStyle for overlay container at host level.any React Native view style

Common Fields

NameTypeRequiredDefaultDescriptionAllowed options/values
presetToastHostPresetno"default"Applies preset before explicit overrides.default, minimal, status, banner-heavy
debugbooleannofalseEnables host-scoped debug logs.true, false
themeToastThemeno"auto"Template theme mode.auto, light, dark
directionToastDirectionno"auto"Toast template direction override independent of app layout direction.auto, ltr, rtl
onConfigChange(context: ToastHostConfigChangeContext) => voidnononeFires after effective host config changes; existing host toasts are dismissed programmatically before callback.callback
durationnumber | "persistent"no4000Default host toast duration fallback.positive number or persistent
variantDurationsPartial<Record<ToastVariant, number | "persistent">>no{ loading: "persistent" }Per-variant duration overrides.variant keyed map
positionToastPositionno"top"Host stack position.top, bottom
maxStackSizenumberno48Hard cap before oldest non-closing entries are trimmed.integer >=1
stackGapnumberno8Stack spacing.number >=0
stackOverlapnumberno10Depth overlap offset.clamped numeric range
deEmphasizebooleannotrueEnables depth de-emphasis transforms.true, false
deEmphasizeScaleStepnumberno0.03Scale step per stack depth.clamped numeric range
deEmphasizeOpacityStepnumberno0.005Opacity step per stack depth.clamped numeric range
dedupeModeToastDedupeModeno"reset"Host-level dedupe strategy fallback.reset, replace, ignore, bump
groupBehaviorToastGroupBehaviorno"stack-in-group"Host-level group behavior fallback.replace-in-group, update-in-group, stack-in-group
priorityModeToastPriorityModeno"soft"Host-level priority sort mode.soft, strict
priorityWeightnumberno6000Weighted priority multiplier for soft mode ordering.clamped numeric range
dismissiblebooleannotrueUser-dismiss permission fallback.true, false
showDismissButtonbooleannofalseDismiss button visibility fallback.true, false
animationPresetToastAnimationPresetno"subtle"Host animation preset fallback.subtle, spring, snappy
animationDurationnumberno260Host animation duration fallback.clamped numeric range
keyboardAvoidancebooleannotrueKeyboard overlap avoidance fallback.true, false
keyboardOffsetnumberno0Keyboard avoidance offset fallback.number >=0
pauseOnDragbooleannotruePauses timer on drag interaction.true, false
pauseOnPressbooleannotruePauses timer on press interaction.true, false
zIndexBasenumberno10000Host z-index base.number
zIndexStepnumberno10Step per stacked layer.integer >=1
layering"newer-on-top" | "older-on-top"no"newer-on-top"Layering strategy.newer-on-top, older-on-top
defaultTemplateToastTemplateno"compact"Host template fallback when toast template omitted.compact, banner
useRNScreensOverlaybooleannofalseEnables RN Screens FullWindowOverlay path when available.true, false
rnScreensOverlayViewStyleStyleProp<ViewStyle>nononeStyle for overlay container.any React Native view style
classNamestringnononeHost container class name.any string
styleStyleProp<ViewStyle>nononeHost container style.any React Native view style

Classic-Only Fields

These fields apply when host interactionMode is classic.

NameTypeRequiredDefaultDescriptionAllowed options/values
classicMaxVisiblenumberno2Classic-mode non-closing visible window target.integer >=1
classicOverflowModeToastStackOverflowModeno"compact"Classic-mode overflow rendering mode.fade, compact, clip
classicOverflowBuffernumberno2Classic-mode additional render buffer beyond classicMaxVisible.integer >=1
classicGestureToastClassicGestureConfignoglobal { enabled: true, dismissThreshold: 48, cancelThreshold: 14, velocityThreshold: 900 } + itemDismiss inheriting global valuesClassic-mode gesture policy for item dismiss interactions. Nested keys override global values per gesture.object

Deck-Only Fields

These fields apply when host interactionMode is deck.

NameTypeRequiredDefaultDescriptionAllowed options/values
deckCollapsedMaxVisiblenumberno4Collapsed deck visible window size.integer >=1
deckExpandedMaxVisiblenumberno32Expanded deck visible window size cap.integer >=1
deckGestureToastDeckGestureConfignoglobal { enabled: true, dismissThreshold: 48, cancelThreshold: 14, velocityThreshold: 900 } + per-gesture keys inheriting global valuesDeck-mode gesture policy. Supports itemDismiss, collapsedExpand, collapsedDismissAll, and collapseHandle.object
allowCollapsedFrontHorizontalDismissbooleannotrueEnables horizontal dismiss for front collapsed card.true, false
disableSwipeDismissAllbooleannofalseDisables collapsed opposite-direction swipe dismiss-all gesture.true, false
collapseHandleStyleToastCollapseHandleStyleno{ width: 48, height: 4, borderRadius: 999, opacity: 0.9, marginTop: 6, marginBottom: 2 } + theme-aware default backgroundVisual style for expanded-mode collapse handle. Drag the handle in collapse direction to collapse (distance or velocity threshold).partial object
dismissAllConfirmationToastDismissAllConfirmationno"default"Dismiss-all confirmation strategy.none, default, custom callback
dismissAllConfirmationTitlestringno"Dismiss all notifications?"Built-in confirmation title.any string
dismissAllConfirmationMessagestringno"This will close all visible toasts in this host."Built-in confirmation message.any string
dismissAllConfirmLabelstringno"Dismiss all"Built-in confirm action label.any string
dismissAllCancelLabelstringno"Cancel"Built-in cancel action label.any string
expandedMaxHeightnumberno0.7Expanded stack height cap. Values in (0,1] are treated as a screen-height ratio; values >1 are treated as pixels.number
expandedAutoCollapseToastExpandedAutoCollapsePolicyno5000Auto-collapse delay in ms or disabled with false.number or false
onStackExpand(context: ToastStackStateContext) => voidnononeFires when deck expands.callback
onStackCollapse(context: ToastStackStateContext) => voidnononeFires when deck collapses.callback
onStackStateChange(context: ToastStackStateContext) => voidnononeFires on expanded state or visible count changes.callback
onDismissAllAttempt(context: ToastDismissAllAttemptContext) => voidnononeFires when dismiss-all attempt starts.callback
onDismissAllComplete(context: ToastDismissAllCompleteContext) => voidnononeFires when dismiss-all attempt resolves.callback

Classic mode contract note:

  • if host interactionMode is classic, deck-only fields are invalid at type level.
  • if host interactionMode is deck, classic-only fields are invalid at type level.
  • collapseHandleStyle applies only while a deck stack is expanded; no handle is shown when collapsed.

ToastOptions Contract

Identity and Flow Fields

NameTypeRequiredDefaultDescriptionAllowed options/values
idToastIdnogenerated idExplicit toast id for update/dedupe targeting.any string id
hostIdstringnocontroller host or provider default hostTarget host id for this toast.any host id string
dedupeKeystringnononeDedupe identity key.any string
dedupeModeToastDedupeModenohost dedupeMode (reset)Dedupe strategy for collisions.reset, replace, ignore, bump
groupIdstringnononeGroup flow id.any string
groupBehaviorToastGroupBehaviornohost groupBehavior (stack-in-group)Group conflict strategy.replace-in-group, update-in-group, stack-in-group
prioritynumbernoeffective 0Priority score used by stack ordering.numeric (runtime clamped)

Content Fields

NameTypeRequiredDefaultDescriptionAllowed options/values
titlestringnononePrimary toast text.any string
descriptionstringnononeSecondary body text.any string
iconReactNodenononeCustom icon node override.any React node
actionsToastAction[]nononeAction buttons for toast.array of ToastAction
templateToastTemplatenohost defaultTemplate (compact)Built-in template selector.compact, banner
render(context: { toast; resolvedTheme; dismiss; update; onPress; onPressIn; onPressOut; onActionPress }) => ReactNodenononeFull custom render override.callback returning React node

Variant and Dismiss Behavior

NameTypeRequiredDefaultDescriptionAllowed options/values
variantToastVariantnodefaultVisual/semantic variant.default, success, error, warning, info, loading
durationnumber | "persistent"nohost/variant resolution (4000, loading persistent)Auto-dismiss duration.positive number or persistent
persistentbooleannoimplementation-defined (loading can force true)Explicit persistence override.true, false
dismissiblebooleannohost dismissible (true)Enables user-driven dismiss reasons.true, false
dismissOnPressbooleannofalseBody press dismiss behavior.true, false
showDismissButtonbooleannohost showDismissButton (false)Template dismiss button visibility.true, false

Layout and Interaction

NameTypeRequiredDefaultDescriptionAllowed options/values
positionToastPositionnohost position (top)Top/bottom placement for toast.top, bottom
directionToastDirectionnohost direction (auto)Per-toast direction override. Final resolution order is toast direction -> host direction -> native/device direction.auto, ltr, rtl
keyboardAvoidancebooleannohost keyboardAvoidance (true)Keyboard overlap avoidance toggle.true, false
keyboardOffsetnumbernohost keyboardOffset (0)Extra keyboard avoidance offset.number >=0
pauseOnDragbooleannohost pauseOnDrag (true)Pause timer while dragging.true, false
pauseOnPressbooleannohost pauseOnPress (true)Pause timer while pressed.true, false

Animation and Gesture

NameTypeRequiredDefaultDescriptionAllowed options/values
animationPresetToastAnimationPresetnohost animationPreset (subtle)Motion preset override.subtle, spring, snappy
animationDurationnumbernohost animationDuration (260)Motion duration override.numeric (runtime clamped)
animationToastAnimationConfignononeCombined animation override object.{ preset?: ToastAnimationPreset; duration?: number }
gestureToastGestureConfignohost item-dismiss gesture config for current modePer-toast item-dismiss gesture override. Applies to toast swipe dismiss behavior only (not deck container gestures).object

Layering and Styling

NameTypeRequiredDefaultDescriptionAllowed options/values
zIndexnumbernononeExplicit z-index override for toast item.any number
classNamestringnononeRoot class name override.any string
styleStyleProp<ViewStyle>nononeRoot style override.any React Native view style
contentClassNamestringnononeTemplate content class name override.any string
contentStyleStyleProp<ViewStyle>nononeTemplate content style override.any React Native view style
titleClassNamestringnononeTitle class name override.any string
titleStyleStyleProp<TextStyle>nononeTitle style override.any React Native text style
descriptionClassNamestringnononeDescription class name override.any string
descriptionStyleStyleProp<TextStyle>nononeDescription style override.any React Native text style
accessibilityLabelstringnononeAccessible label override for rendered toast.any string

Callback Fields

NameTypeRequiredDefaultDescriptionAllowed options/values
onMount(context: callback-context-object) => voidnononeCalled when toast first mounts.callback
onOpen(context: callback-context-object) => voidnononeCalled when toast enters visible state.callback
onUpdate(context: callback-context-object) => voidnononeCalled after successful update.callback
onClose(context: callback-context-object) => voidnononeCalled at close-start phase.callback
onDismiss(context: callback-context-object) => voidnononeCalled at close-end phase.callback
onPress(context: callback-context-object) => voidnononeCalled when toast body is pressed.callback
onActionPress(context: action-context-object) => voidnononeCalled when toast action is pressed.callback
onClosingStart(context: callback-context-object) => voidnononeCalled once when closing starts.callback
onClosingEnd(context: callback-context-object) => voidnononeCalled once when closing completes.callback

ToastUpdateOptions Contract

Signature:

interface ToastUpdateOptions extends Partial<Omit<ToastOptions, "id" | "hostId">> {
reason?: CloseReason;
}
NameTypeRequiredDefaultDescriptionAllowed options/values
...toastFieldsPartial<Omit<ToastOptions, "id" | "hostId">>nononeAny mutable toast field except id and hostId.see ToastOptions tables
reasonCloseReasonnononeOptional update reason metadata used by runtime callbacks and debug flows.timeout, swipe, press, action, dismiss, programmatic

ToastPromiseOptions<T> Contract

Signature:

interface ToastPromiseOptions<T> {
loading: string | ToastOptions;
success?: string | ToastOptions | ((value: T) => string | ToastOptions);
error?: string | ToastOptions | ((error: unknown) => string | ToastOptions);
finally?: ToastUpdateOptions;
hostId?: string;
groupId?: string;
groupBehavior?: ToastGroupBehavior;
priority?: number;
}
NameTypeRequiredDefaultDescriptionAllowed options/values
loadingstring | ToastOptionsyesnoneLoading-state toast payload.string or ToastOptions
successstring | ToastOptions | ((value: T) => string | ToastOptions)nononeSuccess branch payload or builder.string, options object, callback
errorstring | ToastOptions | ((error: unknown) => string | ToastOptions)nononeError branch payload or builder.string, options object, callback
finallyToastUpdateOptionsnononeFinal update applied after success/error branch handling.ToastUpdateOptions
hostIdstringnocontroller host/global default hostHost override for promise flow.host id string
groupIdstringnononeGroup id applied to promise lifecycle toasts.any string
groupBehaviorToastGroupBehaviornohost groupBehaviorGroup behavior override for promise flow.replace-in-group, update-in-group, stack-in-group
prioritynumbernoeffective 0Priority override for promise flow toasts.numeric (runtime clamped)