Interactive demos of hcg-toast, a lightweight zero-dependency JavaScript
toast library powered by toast(). Test typed notifications, sticky toasts,
custom duration, six screen positions, stack limits, pause on hover, custom instances,
and programmatic dismiss - no framework required.
Documentation
Shorthand helpers for success, error,
warning, and info toasts.
toast.success('Changes saved successfully.');
toast.error('Something went wrong.');
toast.warning('Your session expires soon.');
toast.info('New updates are available.');
Optional title plus a longer body to test wrapping.
toast.info(
'Your profile photo was uploaded and is being processed. You will receive a notification when it is ready.',
{
title: 'Upload started',
duration: 6000
}
);
Set duration: 0 to keep a toast visible until the user closes it.
toast.warning('Please review your settings before continuing.', {
title: 'Action required',
duration: 0,
closable: true
});
An 8-second toast with a visible progress bar at the bottom.
toast('This toast stays visible for 8 seconds.', {
duration: 8000,
showProgress: true
});
Use toast.configure({ position }) to move the default container.
toast.configure({ position: 'bottom-right' });
toast.info('Toasts now appear bottom-right.');
Burst 8 toasts; the library keeps at most 5 visible and dismisses the oldest.
toast.configure({ maxToasts: 5 });
for (let i = 1; i <= 8; i++) {
toast.info('Toast #' + i);
}
A 3-second toast that pauses its timer while you hover over it
(pauseOnHover: true by default).
toast('Hover me to pause the timer.', {
duration: 3000,
pauseOnHover: true
});
toast.create() returns an independent instance with its own
container and defaults - useful for a fixed bottom-center banner area.
const bottomToast = toast.create({
position: 'bottom-center',
maxToasts: 3
});
bottomToast.info('Processing your request…', { duration: 0, closable: true });
Show a sticky toast, then dismiss it by id or clear all with
dismissAll().
const id = toast.info('Dismiss me programmatically.', {
duration: 0
});
toast.dismiss(id);
toast.dismissAll();
Override the default type icon with icon (text or emoji),
iconHtml (SVG markup), or hide it with icon: false.
toast.success('Backup complete.', { icon: '💾' });
toast.info('Syncing files…', {
iconHtml: '<svg viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"><path d="M10 3a7 7 0 100 14A7 7 0 0010 3z"/></svg>'
});
toast('Plain message.', { icon: false });