1.0.1-alpha.3 • Published 5 months ago

react-native-toaster-ui v1.0.1-alpha.3

Weekly downloads
-
License
-
Repository
-
Last release
5 months ago

React Native Toaster

A lightweight, customizable toast notification system for React Native applications.

Features

  • 🎨 Multiple toast variants (default, success, error, warning, info)
  • ⏱️ Configurable display duration
  • 🔄 Smooth animations
  • 🧩 Simple API with React hooks
  • 📱 Fully compatible with React Native

Installation

npm install react-native-toaster-ui
# or
yarn add react-native-toaster-ui

Optional Dependencies

This package can use lucide-react-native for icons, but it's optional:

npm install lucide-react-native
# or
yarn add lucide-react-native

If you're using React 19 with React Native 0.78.0 or newer, you may need to install with the --force flag due to compatibility issues with some versions of lucide-react-native:

npm install lucide-react-native --force
# or
yarn add lucide-react-native --force

Usage

1. Wrap your app with the ToastProvider

import { ToastProvider } from 'react-native-toaster-ui';

export default function App() {
  return (
    <ToastProvider>
      {/* Your app content */}
    </ToastProvider>
  );
}

Customization

The toast notifications use predefined styles with appropriate colors for each variant:

  • Default: White background
  • Success: Light green background
  • Error: Light red background
  • Warning: Light yellow background
  • Info: Light blue background

useToast Hook

const { toast, dismiss } = useToast();

toast(options)

Shows a toast notification with the given options.

ParameterTypeDescriptionDefault
titlestringThe title of the toast-
descriptionstringThe description text-
variant'default' | 'success' | 'error' | 'warning' | 'info'The visual style of the toast'default'
durationnumberDuration in milliseconds before auto-dismissing5000

Returns a unique ID that can be used to dismiss the toast.

dismiss(id)

Dismisses a specific toast by its ID.

ParameterTypeDescription
idstringThe ID of the toast to dismiss

License

MIT

1.0.1-alpha.3

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago