KANTO DS v1.12.0
Customise

Theme

Accent

Font

Corners

Density

Text size

Reset to Kanto
Feedback

kt-toast-container / toaster

GitHub Copy link

The stack that owns the toasts on screen, and the imperative shortcut to it.

Preview

Success toast Error toast

The stack that owns the toasts on screen, and the imperative shortcut to it.

toaster — the usual way

import { toaster } from 'kanto-ds'; toaster.success('Entity created'); toaster.error('Could not save', { description: 'Try again in a moment.' });

It creates one <kt-toast-container> on <body> the first time it is called and reuses it — including one you already put in your own markup, which it adopts rather than duplicating.

Defaults that encode the intent: success and info dismiss after 4s, warnings after 6s, and errors never dismiss themselves. An error the user did not happen to be looking at is an error they never saw.

<kt-toast-container> — when placement matters

<kt-toast-container position="top-right" limit="3"></kt-toast-container>container.show({ variant: 'success', heading: 'Entity created', duration: 4000 });

The container owns the toasts: it appends them, and removes them when they ask to go. A toast that removes itself from a list it does not own is how you end up with two on screen and neither leaving.

Newest toasts stack towards the screen edge, so the newest is always nearest the corner. Past limit, the oldest is dropped.

Hovering the stack pauses every countdown, and leaving it resumes them — otherwise a toast expires under the pointer of someone reading it.

The container itself does not intercept pointer events; only the toasts inside it do, so the rest of the corner stays clickable.

API — <kt-toast-container>

PropertyAttributeTypeDefault
positionposition'top-left' | 'top-right' | 'bottom-left' | 'bottom-right''bottom-right'
limitlimitnumber5
Method / getterDescription
show(options)Raises a toast, returns it
dismiss(toast)Removes one
clear()Removes all
toastsThose on screen, oldest first

API — toaster

MemberDescription
success/info/warning/error(heading, options?)Raises a toast, returns it
show(options)The general form
getContainer()The container, creating it if needed
clear()Clears the stack
positionWhere an auto-created container sits

See <kt-toast> for a single notification.