Native Toast
Features

Toast Types & Variants

Learn about each toast type — blank, success, error, loading, and custom.

NativeToast supports five toast types, each with distinct visual treatment and default behavior.

Types Overview

TypeMethodIconDefault DurationUse Case
blanktoast(message)None4000msGeneric notifications
successtoast.success(message)Animated green checkmark SVG2000msPositive confirmations
errortoast.error(message)Animated red X-mark SVG4000msError states
loadingtoast.loading(message)Native ActivityIndicator spinner∞ (never auto-dismisses)Async operations
customtoast.custom(message)None (use icon option)4000msFully custom content

Usage

import { toast } from '@ncrft/native-toast';

// blank — no built-in icon
toast('New message from Alice');

// success — animated checkmark appears
toast.success('Payment received!');

// error — animated X-mark appears
toast.error('Invalid credentials');

// loading — spinner spins, stays until dismissed
const id = toast.loading('Connecting to server…');

// custom — no icon unless you provide one
toast.custom('Gift sent!', { icon: '🎁' });

Message Types

The message parameter accepts multiple formats for maximum flexibility:

// Plain string
toast.success('Done!');

// Any ReactNode — rendered as-is
toast.custom(<View><Text>Complex</Text><Image source={...} /></View>);

// Render function — receives the toast object for conditional rendering
toast.custom((t) => (
  <Text>{t.visible ? 'Showing' : 'Hiding'}</Text>
));

Style Overrides

Every toast type accepts style and textStyle options that are spread onto the toast container and text elements respectively:

toast.success('Saved', {
  style: {
    backgroundColor: '#4CAF50',
    borderRadius: 4,
  },
  textStyle: {
    fontSize: 16,
    fontWeight: 'bold',
  },
});

These overrides take precedence over theme tokens.

Type-Specific Default Durations

TypeAuto-dismisses after
blank4000ms
success2000ms
error4000ms
loadingNever (must be manually dismissed)
custom4000ms

Override any duration with the duration option:

toast.error('Critical failure', { duration: 10000 });

Set duration: Infinity to prevent auto-dismiss on any type.

On this page