React Native Styled Toast

screenshot of React Native Styled Toast
react
react-native

A theme friendly, easy to use react-native toast component built using styled-components and styled-system.

Overview:

The react-native-styled-toast is a fully customizable toast library for React Native. It supports multiple toasts, is compatible with both iOS and Android, and is written using React Hooks and TypeScript.

Features:

  • Pure JS implementation
  • Supports multiple toasts
  • iOS and Android compatible
  • Styled with theme constraints
  • Written using React Hooks
  • Fully typed with TypeScript

Usage:

  1. Wrap your app in the ThemeProvider component from styled-components to ensure that the toasts rely on theming.

  2. Use the ToastProvider and wrap the rest of your app.

  3. Access the Toast context by using the provided useToast hook to trigger a toast anywhere in your app. If you can't use hooks, you can still use the ToastContext.Consumer to fire off a toast.

  4. Configure your theme object to contain at least a spacing scale with some default colors. The theme object should look something like this:

{
  spacing: [0, 4, 8, 16, 32],
  colors: {
    background: '#FFF',
    text: '#000',
    success: '#00FF00',
    info: '#0000FF',
    error: '#FF0000',
    muted: '#888'
  }
}
  1. If your theme object does not contain the required color keys, you can customize these values in the toast configuration object.

Summary:

The react-native-styled-toast library provides a fully customizable toast solution for React Native apps. It supports multiple toasts, is compatible with both iOS and Android, and is written using React Hooks and TypeScript. The library relies on theming and styled-components to style the toasts, and can be easily integrated into any React Native app.

react
React

React is a widely used JavaScript library for building user interfaces and single-page applications. It follows a component-based architecture and uses a virtual DOM to efficiently update and render UI components

react-native
React Native

React Native is a framework for building mobile applications using React and JavaScript. It enables developers to write once and deploy to multiple platforms, including iOS, Android, and the web, while providing a native app-like experience to users.

eslint
Eslint

ESLint is a linter for JavaScript that analyzes code to detect and report on potential problems and errors, as well as enforce consistent code style and best practices, helping developers to write cleaner, more maintainable code.

Expo

An open-source platform for making universal native apps with React. Expo runs on Android, iOS, and the web.

typescript
Typescript

TypeScript is a superset of JavaScript, providing optional static typing, classes, interfaces, and other features that help developers write more maintainable and scalable code. TypeScript's static typing system can catch errors at compile-time, making it easier to build and maintain large applications.