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 🙏

© 2024 – Pkg Stats / Ryan Hefner

simple-tailwind-toast

v1.0.24

Published

A simple toast package for React apps using tailwind.

Downloads

80

Readme

Simple Tailwind Toast

Simple tailwind toast is a simple toast that comes with customizable components styled with TailwindCSS.

A flexible and customizable toast notification component for React applications. This package provides an easy-to-use toast system that can be styled with CSS, SCSS, Less, or Tailwind CSS.

Features

  • Easy integration with React applications
  • Customizable styling options (CSS, SCSS, Less, Tailwind CSS)
  • Flexible positioning of toast notifications
  • Simple API for creating and managing toasts

Installation

Install the package using npm:

npm install simple-tailwind-toast
Or using yarn:
yarn add simple-tailwind-toast

Usage

Here's a basic example of how to use Simple Tailwind Toast in your React application:

import React from 'react';
import {
  SimpleToastProvider,
  SimpleToaster,
  useSimpleToast } from 'simple-tailwind-toast';

const ToastTest = () => {
  return (
    <SimpleToastProvider>
      <ToastMain />
      <SimpleToaster />
    </SimpleToastProvider>
  );
};

const ToastMain = () => {
  const { toast } = useSimpleToast();

  return (
    <div>
      <div className="text-3xl font-bold underline text-red-600">
        Tailwind test!
      </div>
      <br />
      <br />
      <button
        onClick={() => {
          toast.add({
            content: {
              title: 'Hello Toast!',
              description: 'Testing Simple tailwind toast',
            },
          });
        }}
        className="bg-slate-300 text-black p-2 m-2"
      >
        Click to toast
      </button>
    </div>
  );
};

export default ToastTest;

API

SimpleToastProvider Wrap your application with SimpleToastProvider to enable the toast functionality.

SimpleToastProvider: React.FC<"children: React.ReactNode">

SimpleToaster Place SimpleToaster component at the root of your app or any where ever you can have access to the toast provider. You can style the toasts using CSS, SCSS, Less, or Tailwind CSS. The component provides class names that you can target for custom styling.

SimpleToaster: FC<{
    classNames?: ISimpleClassNames;
    position?: TToastPosition;
}>

 TToastPosition = 'bottomCenter'| 'bottomLeft'| 'bottomRight'| 'midCenter'| 'midLeft'| 'midRight' | 'topCenter'| 'topLeft'| 'topRight';)

ISimpleClassNames {
  title?: string;
  description?: string;
  close?: string;
  types?: {
    default?: string;
    error?: string;
    warning?: string;
    success?: string;
  };
}

useSimpleToast A hook that provides the toast object with methods to manage toasts.

 useSimpleToast: () => {
    store: Partial<IToastContextStore>;
    toast: {
        add: (toast: Partial<ISimpleToast>) => void;
        remove: (id: string) => void;
        removeAll: () => void;
    };
}

toast.add

Adds a new toast notification.

  toast.add({
            content: {
              title: 'Hello Toast!',
              description: 'Testing Simple tailwind toast',
            },
          });

content: An object containing title, description and duration (in milliseconds ) for that particular toast

toast.remove

Removes a toast using id

toast.remove(toast.id);

toast.removeAll

Removes all toast notification

  toast.removeAll(toast.id);

Types


TToastPosition =
  | 'bottomCenter'
  | 'bottomLeft'
  | 'bottomRight'
  | 'midCenter'
  | 'midLeft'
  | 'midRight'
  | 'topCenter'
  | 'topLeft'
  | 'topRight';


SimpleClassNames {
  title?: string;
  description?: string;
  close?: string;
  types?: {
    default?: string;
    error?: string;
    warning?: string;
    success?: string;
  };
}


ISimpleToastContent {
  title?: React.ReactNode;
  description?: React.ReactNode;
  type?: 'error' | 'success' | 'warning';
}

 ISimpleToast {
  id: string;
  content: ISimpleToastContent;
  duration: number;
}

IToastContextStore {
  toasts: ISimpleToast[];
}

Customization You can customize the appearance and behavior of toasts by passing props to SimpleToaster or by styling the provided class names. 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.