@aargon-ui/toast
v1.0.0-beta.1
Published
Animated toast component for React Native
Maintainers
Readme
Aargon Toast
A highly customizable, animated toast notification component for React Native with smooth animations and modern design.
Features
- 🎨 Multiple Variants - Default, success, warning, and error styles
- 📏 Size Options - Small, medium, and large sizes
- ⚡ Smooth Animations - Spring, timing, and bounce animations
- 🎯 Accessibility - Full accessibility support with proper ARIA attributes
- 🎨 Customizable Themes - Complete theming system with colors and styling
- 🔧 Flexible API - Easy to use with comprehensive props
- 📱 React Native - Built specifically for React Native with Reanimated
- 🌟 TypeScript - Full TypeScript support with comprehensive types
Installation
npm install @aargon-ui/toast
# or
yarn add @aargon-ui/toastPeer Dependencies
Make sure you have the required peer dependencies installed:
npm install react react-native react-native-reanimatedQuick Start
import React, { useState } from 'react';
import { View, Button } from 'react-native';
import { AnimatedToast } from '@aargon-ui/toast';
export default function App() {
const [visible, setVisible] = useState(false);
return (
<View>
<Button title="Show Toast" onPress={() => setVisible(true)} />
<AnimatedToast visible={visible} onDismiss={() => setVisible(false)} message="This is a toast message" />
</View>
);
}Basic Usage
Simple Toast
const [visible, setVisible] = useState(false);
<AnimatedToast visible={visible} onDismiss={() => setVisible(false)} message="This is a toast message" />;With Icon
<AnimatedToast visible={visible} onDismiss={() => setVisible(false)} message="Success message" icon="check-circle" variant="success" />Auto Dismiss
<AnimatedToast visible={visible} onDismiss={() => setVisible(false)} message="Auto dismiss in 3 seconds" duration={3000} />Variants
Default Variant
<AnimatedToast variant="default" message="Default message" />Success Variant
<AnimatedToast variant="success" message="Success message" />Warning Variant
<AnimatedToast variant="warning" message="Warning message" />Error Variant
<AnimatedToast variant="error" message="Error message" />Sizes
<AnimatedToast size="sm" message="Small toast" />
<AnimatedToast size="md" message="Medium toast" />
<AnimatedToast size="lg" message="Large toast" />Animation Types
Spring Animation (Default)
<AnimatedToast animationType="spring" message="Spring animation" />Timing Animation
<AnimatedToast animationType="timing" duration={500} message="Timing animation" />Bounce Animation
<AnimatedToast animationType="bounce" message="Bounce animation" />Custom Styling
Custom Theme
const customTheme = {
colors: {
background: '#3B82F6',
text: '#FFFFFF',
icon: '#93C5FD',
},
borderRadius: 8,
};
<AnimatedToast theme={customTheme} message="Custom theme" />;With Shadow
<AnimatedToast shadow={true} message="With shadow" />Advanced Usage
Custom Position
<AnimatedToast visible={visible} onDismiss={() => setVisible(false)} message="Top positioned" position="top" />Custom Duration
<AnimatedToast visible={visible} onDismiss={() => setVisible(false)} message="Custom duration" duration={5000} />Disabled State
<AnimatedToast disabled={true} message="Disabled" />Custom Icon
<AnimatedToast visible={visible} onDismiss={() => setVisible(false)} message="Custom icon" icon="star" iconColor="#FFD700" />API Reference
Props
| Prop | Type | Default | Description |
| --------------- | ------------------------------------------------ | ----------- | --------------------------------------- |
| visible | boolean | false | Whether the toast is visible |
| onDismiss | () => void | - | Function called when toast is dismissed |
| message | string | - | Toast message text |
| icon | string | - | Icon name from @expo/vector-icons |
| iconColor | string | - | Color of the icon |
| variant | "default" \| "success" \| "warning" \| "error" | "default" | Visual variant |
| size | "sm" \| "md" \| "lg" | "md" | Size of the toast |
| animationType | "timing" \| "spring" \| "bounce" | "spring" | Type of animation |
| duration | number | 4000 | Auto dismiss duration in milliseconds |
| position | "top" \| "bottom" | "bottom" | Position of the toast |
| disabled | boolean | false | Whether the toast is disabled |
| theme | ToastTheme | - | Custom theme object |
| shadow | boolean | false | Whether to show shadow effect |
Types
interface ToastTheme {
colors: {
background: string;
text: string;
icon: string;
shadow: string;
};
borderRadius: number;
fontFamily?: string;
}
type ToastVariant = 'default' | 'success' | 'warning' | 'error';
type ToastSize = 'sm' | 'md' | 'lg';
type AnimationType = 'timing' | 'spring' | 'bounce';
type ToastPosition = 'top' | 'bottom';Accessibility
The toast component includes full accessibility support:
- ARIA attributes - Proper
role="alert"andaria-liveattributes - Screen reader support - Announces messages to screen readers
- High contrast support - Works well with system accessibility settings
Requirements
- React Native 0.81.0+
- React 19.0.0+
- react-native-reanimated 3.0.0+
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
If you have any questions or need help, please:
- Check the documentation
- Search existing issues
- Create a new issue
Changelog
See CHANGELOG.md for a list of changes and version history.
Made with ❤️ by Aargon
