A modern TypeScript implementation of Toastr - Beautiful toast notifications for web applications
Try the different toast types with default settings:
npm install toastr-ts
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
});
<!-- 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>
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>
);
}