🎉 Toastr-TS

A modern TypeScript implementation of Toastr - Beautiful toast notifications for web applications

View on GitHub npm Package

Quick Demo

Try the different toast types with default settings:

Customize Toast

Installation & Usage

Install via npm

npm install toastr-ts

Usage (ES Modules)

import Toastr from 'toastr-ts';

const toastr = new Toastr();

// Show notifications
toastr.success('Operation successful!');
toastr.error('Something went wrong!');
toastr.info('Here is some info');
toastr.warning('Be careful!');

// With title
toastr.success('Settings saved', 'Success!');

// With custom options
toastr.info('Custom message', 'Info', {
  timeOut: 3000,
  progressBar: true,
  closeButton: true
});

Include via CDN

<!-- Add the script tag -->
<script src="https://unpkg.com/toastr-ts/dist/toastr.umd.js"></script>

<script>
  // Create instance
  const toastr = new window.toastr();
  
  // Show notifications
  toastr.success('It works!');
  toastr.error('Error message');
  toastr.info('Info message');
  toastr.warning('Warning message');
</script>

React/TypeScript

import { useState } from 'react';
import Toastr from 'toastr-ts';

function MyComponent() {
  const [toastr] = useState(() => new Toastr());
  
  const handleClick = () => {
    toastr.success('Action completed!');
  };
  
  return (
    <button onClick={handleClick}>
      Show Toast
    </button>
  );
}

Key Features

  • ✨ Modern TypeScript implementation
  • 📦 Zero runtime dependencies
  • 🎨 Styles bundled (no separate CSS import needed)
  • ⚡ Framework-agnostic (works with React, Vue, Angular, etc.)
  • 🌐 UMD & ESM builds included
  • 📱 Responsive design
  • ♿ Accessible (ARIA attributes)
  • 🎯 Fully customizable