Fully programmatic toast notifications — no HTML needed. Toasts are created and injected into the DOM at runtime via the
WojoToast
static API. Seven position presets, four type shorthands, an optional countdown progress bar, and configurable animations.
Types
Four shorthand methods for common notification types, plus a neutral
show()
with no type set.
Type Shorthands
Each shorthand sets the icon, color, and role automatically. By default, the previous toast is dismissed before the new one appears.
JavaScript
import { WojoToast } from './src/js/components/wf-toast.js'
WojoToast.success('Changes saved successfully.')
WojoToast.error('Something went wrong.')
WojoToast.warning('Storage is almost full.')
WojoToast.info('A new version is available.')
// Neutral — no type, no icon
WojoToast.show({ text: 'Your file was uploaded.' })
With Title
Add a bold heading above the body text with the
title
option. All type shorthands accept an option second argument.
Title via
show()
Pass
title
in the option’s object to add a heading above the body.
JavaScript
WojoToast.show({
title: 'Upload complete',
text: 'Your file has been uploaded successfully.',
type: 'positive',
})
// Shorthand with title in options
WojoToast.error('Please check your connection.', {
title: 'Connection failed',
})
Dynamic update
Call
item.update()
to change the text or title while the toast is still visible.
JavaScript
const item = WojoToast.show({
title: 'Uploading…',
text: '0 of 3 files done.',
type: 'info',
duration: false, // sticky while we update it
})
// Later — update in place without closing
setTimeout(() => {
item.update({ title: 'Done!', text: '3 of 3 files uploaded.' })
}, 2000)
Positions
Seven position presets. The default is
top-right
. Position demos use
exclusive: false
so toasts stack per-position.
All Positions
Each container is created lazily the first time a toast targets that position.