react-native-animated-toast-alerts

React Native Animated Toast

TypeScript Java PRs Welcome License

A modern, highly customizable animated toast notification library for React Native featuring stacking animations, gesture support, and comprehensive TypeScript compatibility.

react-native-animated-toast-alerts

Installation β€’ Usage β€’ Customization β€’ API Reference


✨ Features


πŸš€ Installation

1. Install the package and dependencies

# Using npm
npm install react-native-animated-toast-alerts lucide-react-native react-native-svg

# Using yarn
yarn add react-native-animated-toast-alerts lucide-react-native react-native-svg

# Using pnpm
pnpm add react-native-animated-toast-alerts lucide-react-native react-native-svg

2. iOS Setup

Run the following command to install the required CocoaPods dependencies:

cd ios && pod install && cd ..

🎯 Quick Start

Wrap your Application with the ToastProvider

import { ToastProvider } from 'react-native-animated-toast-alerts';

const App = () => {
  return (
    <ToastProvider>
      <YourApp />
    </ToastProvider>
  );
};

export default App;

Display a Toast

import { useToast } from 'react-native-animated-toast-alerts';
import { Camera } from 'lucide-react-native';

const MyComponent = () => {
  const { showToast } = useToast();

  const handlePress = () => {
    showToast({
      type: 'success',
      message: '✨ Operation completed!',
      position: 'top',
      icon: {
        icon: Camera,
        props: {
          size: 24,
          color: '#16A34A'
        }
      }
    });
  };

  return <Button title="Show Toast" onPress={handlePress} />;
};

🎨 Toast Types

Predefined Toast Types

// ℹ️ Info toast
showToast({
  type: 'info',
  message: 'Updates available',
});

// βœ… Success toast
showToast({
  type: 'success',
  message: 'Changes saved!',
});

// ❌ Error toast
showToast({
  type: 'error',
  message: 'Something went wrong',
});

// ⚠️ Warning toast
showToast({
  type: 'warning',
  message: 'Please review input',
});

πŸ’… Customization

Styling Options

showToast({
  type: 'info',
  message: 'Custom styled toast',
  position: 'center',
  customStyle: {
    borderRadius: 12,
    backgroundColor: '#F8FAFC',
  },
  messageStyle: {
    fontSize: 16,
    fontWeight: 'bold',
  },
});

Custom Icons

import { AlertCircle } from 'lucide-react-native';

showToast({
  type: 'info',
  message: 'Custom icon toast',
  icon: {
    icon: AlertCircle,
    props: {
      size: 24,
      color: '#1D4ED8',
      strokeWidth: 2
    }
  }
});

πŸ“š API Reference

ToastOptions

interface ToastOptions {
  type?: 'info' | 'success' | 'error' | 'warning';
  message: string;
  duration?: number;
  position?: 'top' | 'bottom';
  icon?: ToastIcon;
  customStyle?: StyleProp<ViewStyle>;
  messageStyle?: StyleProp<TextStyle>;
}

type ToastIcon = {
  icon: LucideIcon | React.ComponentType<any>;
  props?: {
    size?: number;
    color?: string;
    [key: string]: any;
  };
};

πŸ“± Platform Specific Features

The library provides optimized experiences for both platforms:


πŸ”§ Technical Requirements


🀝 Contributing

Contributions are welcome! Please feel free to submit issues and pull requests. For major changes, kindly open a discussion first.


πŸ“„ License

MIT Β© Rajeshwar Kashyap


Made with ❀️ by Rajeshwar Kashyap