npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-native-lq-toast

v1.0.19

Published

A customizable toast component for React Native.

Readme

react-native-lq-toast

A lightweight and customizable toast notification library for React Native. It supports animations, different toast variants, and allows users to pass a custom component for the toast design.

🎥 Demo

Here’s how the toast appears from the top and bottom:

Top Toast, 'Bottom Toast

📦 Installation

npm install react-native-lq-toast

or using Yarn:

yarn add react-native-lq-toast

🚀 Usage

1⃣ Wrap Your App with ToastProvider

To use the toast system, wrap your app with the ToastProvider.

import React from "react";
import { ToastProvider } from "react-native-lq-toast";
import HomeScreen from "./HomeScreen";

const App = () => {
    return (
        <ToastProvider position="top" animationType="slide">
            <HomeScreen />
        </ToastProvider>
    );
};

export default App;

2⃣ Use useToast() Hook to Show Toasts

Inside any component, you can use the useToast hook to show or hide toasts.

import React from "react";
import { View, Button } from "react-native";
import { useToast } from "react-native-lq-toast";

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

    return (
        <View>
            <Button
                title="Show Success Toast"
                onPress={() =>
                    showToast({
                        title: "Success",
                        description: "Your action was successful!",
                        variant: "success",
                    })
                }
            />

            <Button
                title="Show Error Toast"
                onPress={() =>
                    showToast({
                        title: "Error",
                        description: "Something went wrong.",
                        variant: "error",
                    })
                }
            />
        </View>
    );
};

export default HomeScreen;

3⃣ Customize Toast Position and Animation

By default, the toast appears at the top of the screen with a slide animation, but you can customize both:

<ToastProvider position="bottom" animationType="fade">
    <HomeScreen />
</ToastProvider>

4⃣ Passing a Custom Toast Component

You can pass a custom component for the toast UI while still using the built-in animation:

const CustomToast = ({ title, description, onDismiss }) => {
    return (
        <View
            style={{ backgroundColor: "black", padding: 10, borderRadius: 5 }}
        >
            <Text style={{ color: "white", fontWeight: "bold" }}>{title}</Text>
            <Text style={{ color: "white" }}>{description}</Text>
            <Button title="Close" onPress={onDismiss} />
        </View>
    );
};

<ToastProvider
    position="top"
    animationType="slide"
    customComponent={() => (
        <CustomToast
            title="Custom Title"
            description="Custom Description"
            onDismiss={() => console.log("closed")}
        />
    )}
>
    <HomeScreen />
</ToastProvider>;

5⃣ Setting Toast Duration and Offsets

You can control how long the toast remains visible using the duration prop in both ToastProvider and showToast. Additionally, you can adjust the toast's position using offsetTop and offsetBottom.

<ToastProvider
    position="top"
    animationType="fade"
    duration={4000}
    offsetTop={60}
    offsetBottom={100}
>
    <HomeScreen />
</ToastProvider>
showToast({
    title: "Info",
    description: "This message will disappear in 5 seconds.",
    variant: "warning",
    duration: 4000,
});

What’s Improved?

✅ Toast moves above the keyboard when position="bottom"
✅ Uses Keyboard.addListener() to track the keyboard height dynamically
✅ Keeps original offsetTop and offsetBottom behavior intact
✅ Supports animationType prop: "slide" and "fade"

🎨 Toast Variants

| Variant | Icon | Default Background | | ------- | ---- | ------------------ | | success | ✅ | #EFFAF6 | | error | ❌ | #FDEDF0 | | warning | ⚠️ | #FFF4E5 |

🛠 API Reference

ToastProvider Props

| Prop | Type | Default | Description | | ---------------------- | ------------------------------- | --------- | ------------------------------------------------- | | position | 'top' \| 'center' \| 'bottom' | 'top' | Position of the toast. | | animationType | 'slide' \| 'fade' | 'slide' | Animation type for toast appearance. | | customToastComponent | ReactNode | null | Custom toast component. | | duration | number | 4000ms | Duration before toast disappears (ms). | | offsetTop | number | 60 | Offset from the top when position is "top". | | offsetBottom | number | 100 | Offset from the bottom when position is "bottom". |

useToast() Methods

| Method | Arguments | Description | | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------ | | showToast | { title: string, description?: string, variant?: 'success' \| 'error' \| 'warning', animationType?: 'slide' \| 'fade', duration?: number, offsetTop?: number, offsetBottom?: number } | Displays a toast. | | hideToast | () | Hides the current toast. |

This makes sure the toast never overlaps the keyboard when appearing at the bottom! 🚀

📝 License

This project is licensed under the MIT License.


Now you're all set to use react-native-lq-toast in your project! 🚀🔥