Skip to main content

Toast

shadow

The Toast component provides an unobtrusive way of displaying short notifications to the user. They are designed to appear and disappear seamlessly, ensuring that important information reaches users without being intrusive.

Stacked toasts and positions

Toast also supports a layered stack via the stacked attribute. Combined with stack-position="top-center" or stack-position="bottom-center", notifications are stored in the center of the screen, the newest one stays on top, and older toasts shrink in the collapsed state. On hover, the stack expands to full size in the order in which they were created. You can use the same stack mode in corners via top-start, top-end, bottom-start and bottom-end. In the demo below you can change the mode, position and colour of the toast via the selects.

Stack configuration

  • The stacked enables the new layered mode without changing the default behavior of regular toasts.
  • The stack-position specifies the location of the stack. For centered mode, use top-center or bottom-center.
  • The stack-depth specifies the number of visual levels in the collapsed state. The default value is 3.

When to use

Use wje-toast when you need to immediately communicate a status, the result of an action, or the next step to the user.

When not to use

Don't use multiple competing feedback channels at the same time for one event.

Accessibility

Communicate message status through appropriate ARIA live regions and manage focus (open/close) for modal elements.

  • Select the severity of the messages (info/success/warning/error) according to the real impact on the user.
  • For blocking actions, prefer confirmation only where irreversible change is imminent.
  • Set consistent timeouts so the user has time to read the message.
  • For larger numbers of toasts, use stacked and appropriate stack-depth to keep the stack readable.
  • For a centered stack, we recommend setting a uniform width via --wje-toast-stack-width.

Attributes and properties

closable

PopisUrčuje, či je voľba closable zapnutá a ovplyvňuje správanie komponentu.
Atribútclosable
Typboolean
Predvolenéfalse

color

PopisNastavuje farbu komponentu.
Atribútcolor
Typstring
Predvolené-

countdown

PopisUrčuje, či je voľba countdown zapnutá a ovplyvňuje správanie komponentu.
Atribútcountdown
Typboolean
Predvolenéfalse

duration

PopisNastavuje číselnú hodnotu používanú vo voľbe duration.
Atribútduration
Typnumber
Predvolené-

headline

PopisNastavuje textovú hodnotu uloženú vo voľbe headline.
Atribútheadline
Typstring
Predvolené-

icon

PopisNastavuje názov ikony použitej v komponente.
Atribúticon
Typstring
Predvolené-

open

PopisUrčuje, či je voľba open zapnutá a ovplyvňuje správanie komponentu.
Atribútopen
Typboolean
Predvolenéfalse

stackDepth

PopisNastavuje číselnú hodnotu používanú vo voľbe stack-depth.
Atribútstack-depth
Typnumber
Predvolené-

stackPosition

PopisNastavuje stack position, ktorý používa logika stavu komponentu.
Atribútstack-position
Typstring
Predvolené-

stacked

PopisUrčuje, či je voľba stacked zapnutá a ovplyvňuje správanie komponentu.
Atribútstacked
Typboolean
Predvolenéfalse

Events

NázovPopis
wje-toast:after-showVyvolá sa pri odoslaní udalosti wje-toast:after-show.
wje-toast:after-hideVyvolá sa pri odoslaní udalosti wje-toast:after-hide.

Methods

createToastStack

PopisVytvorí toast stack a pripojí ho do štruktúry komponentu.
Signatúra() => HTMLDivElement

getToastStackKey

PopisVráti toast stack key z aktuálneho stavu komponentu.
Signatúra() => string

applyToastStackPlacement

PopisSpustí metódu applyToastStackPlacement na vykonanie logiky komponentu a aktualizáciu jeho stavu.
Signatúra(stack: HTMLDivElement) => void

syncToastStack

PopisSynchronizuje toast stack s externým alebo interným zdrojom stavu.
Signatúra(stack: HTMLDivElement) => void

clearStackItemStyles

PopisVyčistí stack položku styles a obnoví súvisiace hodnoty.
Signatúra(toast: Toast) => void

getToastVisualHeight

PopisVráti toast visual height z aktuálneho stavu komponentu.
Signatúra(toast: Toast) => number

updateToastStack

PopisAktualizuje toast stack podľa najnovších údajov komponentu.
Signatúra(stack: HTMLDivElement) => void

CSS shadow parts

NázovPopis
nativeŠtýluje koreňovú shadow časť komponentu.

CSS custom variables

NázovPopis
--wje-toast-stack-widthVlastná CSS premenná, ktorá riadi šírku kontajnera stacku toastov.

Slots

NázovPopis
defaultPredvolený slot pre hlavný obsah komponentu.
mediaSlot pre mediálny obsah.