Skip to main content
Version: 1.3.x

API Components

Platform support (current): iOS and Android only. Web is not officially supported yet and may be added in future releases.

Contract details for component value exports. Import from package root only:

import {
ToastProvider,
ToastHost,
ToastViewport,
ToastNativeSurfaceBoundary,
ToastVariantIcon,
ToastDismissIconButton,
} from "react-native-toast-system";

Value Exports

ToastProvider

Signature:

function ToastProvider(props: ToastProviderProps): JSX.Element;

ToastProviderProps

NameTypeRequiredDefaultDescriptionAllowed options/values
childrenReactNodenononeProvider subtree content.any React node
defaultHostIdstringno"default"Default host id used by toast and useToast() when host is omitted.any non-empty string
defaultHostConfigToastHostConfignononeDefault host behavior overrides merged into runtime host defaults. Runtime updates are re-applied to mounted hosts while preserving each host's local overrides.valid ToastHostConfig object
debugbooleannononeProvider-level debug fallback for default host if defaultHostConfig.debug is omitted.true, false
useRNScreensOverlaybooleannononeProvider-level overlay fallback for default host if defaultHostConfig.useRNScreensOverlay is omitted.true, false
rnScreensOverlayViewStyleStyleProp<ViewStyle>nononeProvider-level overlay view style fallback for default host.any React Native view style

Template registration note:

  • ToastProvider no longer accepts a templates prop.
  • Register custom templates through createToastSystem({ templates }).

ToastHost and ToastViewport

Signatures:

function ToastHost(props: ToastHostProps): JSX.Element | null;
const ToastViewport: typeof ToastHost;

ToastViewport is an alias of ToastHost.

ToastHostProps / ToastViewportProps

NameTypeRequiredDefaultDescriptionAllowed options/values
hostIdstringnoprovider defaultHostIdHost namespace key.any non-empty string
configToastHostConfignononeHost-scoped config overrides merged at registration time.valid ToastHostConfig object
classNamestringnononeClass name applied to host container.any string
styleStyleProp<ViewStyle>nononeStyle applied to host container.any React Native view style
controllerRefRef<ToastController | null>nononeReceives mounted host controller instance. Cleared on unmount.React ref
useRNScreensOverlaybooleannononeHost-level overlay override when config.useRNScreensOverlay is omitted.true, false
rnScreensOverlayViewStyleStyleProp<ViewStyle>nononeHost-level overlay style override when config.rnScreensOverlayViewStyle is omitted.any React Native view style

ToastNativeSurfaceBoundary

Signature:

function ToastNativeSurfaceBoundary(props: ToastNativeSurfaceBoundaryProps): JSX.Element;

ToastNativeSurfaceBoundaryProps

NameTypeRequiredDefaultDescriptionAllowed options/values
childrenReactNodenononeBoundary subtree content.any React node
classNamestringnononeClass name forwarded to GestureHandlerRootView.any string
styleStyleProp<ViewStyle> (ViewProps)no[ { flex: 1 }, style ] mergeStyle forwarded to boundary root view.any React Native view style
unstable_forceActivebooleannotrueForwarded unstable gesture-handler activation hint.true, false
...restViewPropsnononeRemaining React Native ViewProps forwarded to boundary root view.valid ViewProps fields

ToastVariantIcon

Signature:

function ToastVariantIcon(props: {
variant?: ToastVariant;
color: string;
size?: number;
className?: string;
}): JSX.Element | null;

Variant Icons Props Contract

NameTypeRequiredDefaultDescriptionAllowed options/values
variantToastVariantno"default"Variant icon to render. loading renders spinner.default, success, error, warning, info, loading
colorstringyesnoneIcon/stroke fill color.any CSS-like color string accepted by RN/SVG
sizenumberno16Icon frame size in device-independent pixels.positive number
classNamestringnononeOptional class name for icon frame.any string

ToastDismissIconButton

Signature:

function ToastDismissIconButton(props: {
accessibilityLabel: string;
accessibilityHint?: string;
onPress: () => void;
onPressIn?: () => void;
onPressOut?: () => void;
iconColor: string;
iconSize?: number;
className?: string;
style?: StyleProp<ViewStyle>;
}): JSX.Element;

Dismiss Icon Props Contract

NameTypeRequiredDefaultDescriptionAllowed options/values
accessibilityLabelstringyesnoneAccessible label for dismiss button.any non-empty string
accessibilityHintstringnononeAccessible hint text.any string
onPress() => voidyesnoneDismiss trigger callback.function
onPressIn() => voidnononePress-in callback (often for timer pause wiring).function
onPressOut() => voidnononePress-out callback (often for timer resume wiring).function
iconColorstringyesnoneClose icon color.any CSS-like color string accepted by RN/SVG
iconSizenumberno18Close icon size.positive number
classNamestringnononeOptional button class name.any string
styleStyleProp<ViewStyle>nononeOptional button style.any React Native view style