1.0.1 • Published 2 years ago

react-toasties v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

React Toast Component

A customizable and easy-to-use toast component for React applications.

Installation

To install the package, use npm or yarn:

npm install react-toasties

or

yarn add react-toasties

Usage

Import the Toast component and use it in your React application:

import React from "react";
import Toast from "react-toasties";
import "react-toasties/dist/Toast.css"; // Make sure to import the CSS file

function App() {
  const handleClose = () => {
    // Handle toast close
  };

  return (
    <div className="app-container">
      {/* Your application content */}
      <Toast
        message="This is a toast message"
        duration={5000}
        onClose={handleClose}
        position="top-right"
        showCloseButton={true}
        customClassName="custom-toast"
        showProgress={true}
      />
    </div>
  );
}

export default App;

Props

PropTypeDefaultRequiredDescription
messageReact.ReactNodeYesThe message to be displayed in the toast.
durationnumberYesDuration in milliseconds for how long the toast should remain visible.
onClose() => voidYesCallback function when the toast is closed.
positionstring'top-right'NoPosition of the toast on the screen. Possible values: top-left, top-right, bottom-left, bottom-right, top-center, bottom-center.
showCloseButtonbooleantrueNoDetermines whether the close button should be shown.
customClassNamestringNoAdditional custom class name for custom styling.
showProgressbooleanfalseNoDetermines whether the progress bar should be shown.

License

This project is licensed under the MIT License - see the LICENSE file for details.

1.0.1

2 years ago

1.0.0

2 years ago