DesignOverviewDesign SystemMapsGraphIntroductionInstallationDeriving a themeSandboxTheme builderVisual testingAgentsCortexMemoryActiveProvenanceActiveContextActiveServicesInsightsGet in touchSource on GitHub
Loading the reference
ToastView sourceEdit in SandboxView MarkdownCopy MarkdownOpen in ClaudeOpen in CursorThe region that holds toast messages, and the only element that announces them.Also called Toaster and Snackbar.StableSince 0.1.0OverlaysImportimport'@fusion.dev/helix/toast'import'@fusion.dev/helix-headless/toast'Preview
GuidelinesWhen to use
A confirmation of something you just did, such as saving a change.ToastThis page
Do an action that can be undone, then call undoable().The message holds an Undo button and shows for 8 seconds, which replaces a confirmation dialog.<helix-flexdirection="column"gap="md"><helix-listdividedid="files"label="Files"><helix-list-item>
Quarterly report.pdf
<helix-buttondata-archiveslot="end">Archive</helix-button></helix-list-item><helix-list-item>
Roadmap.key
<helix-buttondata-archiveslot="end">Archive</helix-button></helix-list-item></helix-list><helix-toastid="stack"label="Notifications"placement="bottom-end"></helix-toast></helix-flex><scripttype="module">constfiles=document.getElementById('files')conststack=document.getElementById('stack')/* The action happens at once. The message offers to take it back, which replaces asking first. */files.addEventListener('click',(event)=>{constbutton=event.target.closest('[data-archive]')if(!button){return}constrow=button.closest('helix-list-item')constnext=row.nextElementSiblingconstname=row.firstChild.textContent.trim()row.remove()stack.undoable(`Archived ${name}`,{undo:()=>files.insertBefore(row,next),})})</script>
Call add() to show a message from a page with no framework state.It appends a message and removes it once it is dismissed, and the messages you render stay yours.
Render a second region inside a modal dialog for a message with an action.While a modal is open, a message outside it stays visible, and its actions cannot be pressed.
Anatomy
1::part(region)The stack the messages are in. It is in the top layer while a message shows, and takes focus from hotkey where no message holds a control.
2<helix-toast-item>One message in the toast region.
API referenceRoothelix-toastThe region that holds toast messages, and the only element that announces them.
PropTypeDescriptionfallbackLabelstringDefault"Notifications ({hotkey})"The name the element gives itself where label is empty.hotkeystringDefault"F8"The key that takes focus to the stack and back, such as F8 or Alt+T:
keys joined by +, the last one the key, as Announcement's hotkey
reads them: mod is Command on Apple devices and Control elsewhere.
Empty turns it off.hotkeyLabelstringDefault"Go to notifications"What the hotkey does, as a list of the page's shortcuts says it.labelstringDefault""Accessible name for the region, with {hotkey} filled in. Translate it with
the rest of your interface.maxVisiblenumberHow many messages show at once. The messages after that many wait, hidden
and with their timers stopped, until a message before them goes. Unset,
every message shows.placement"bottom-center"|"bottom-end"|"bottom-start"|"top-center"|"top-end"|"top-start"Which corner or edge the stack sits at.swipeDirection"bottom"|"end"|"start"|"top"The edge a touch or a pen swipes a message toward to dismiss it: end,
the end of the line, or start, top, or bottom. Unset is the inline
edge the stack sits at: start for a placement ending in start, and
end for every other.undoHintstringDefault"Press {keys} to undo."What a message undoable() made says after its own words, with {keys}
for the chord that undoes it, spoken as words.undoKeysstringDefault"mod+z"The keys that undo the newest message undoable() made, as hotkey
reads them. Empty turns them off, for an app whose own undo holds them,
and leaves the Undo button. A key the app already handled, by calling
preventDefault(), is left to it.undoLabelstringDefault"Undo"The words on the Undo button of a message undoable() made.
ReadTypeDescriptionwhenSettledPromise<void>Resolves a frame after the first update, when transitions are switched on.
SlotDescription(default)The messages.
EventTypeDescriptionhelix-dismissHelixDismissEventA message is being dismissed, by its control or by its timer. The message sends it, and you can listen for it on the region. Cancelable: canceling it keeps the message.
MethodTypeDescriptionadd(message: string, options: {
action?: Elementdismissible?: booleanduration?: numberheading?: stringtone?: "danger" | "info" | "success" | "warning"
}) => HTMLElementShows a message from script, and returns the element.undoable(message: string, options: {
commit?: () => voidduration?: numberheading?: stringtone?: "danger" | "info" | "success" | "warning"undo: () => void
}) => Promise<"kept" | "undone">Shows that an action happened and offers to undo it, which is the pattern
that replaces a confirmation dialog for an action that can be taken back.
PartDescriptionliveThe two regions that say each message as it arrives, a polite status and an assertive alert, inside the stack. Empty at rest, and hide them with the standard clip, never display: none.regionThe stack the messages are in. It is in the top layer while a message shows, and takes focus from hotkey where no message holds a control.
CSS PropertyDescription--toast-gapSpace between one message and the next.--toast-inline-sizeWidth of a message.--toast-insetDistance from the edges of the window.
Custom stateDescriptionsettledSet one frame after the first render. Transitions wait for it, so an element does not animate its own arrival.
Itemhelix-toast-itemOne message in the toast region.
PropTypeDescriptiondismissiblebooleanDefaultfalseWhether the element shows a control that dismisses it.dismissLabelstringDefault"Dismiss"The dismiss control's label, read by screen readers.durationnumberHow long the message stays, in milliseconds. When it is not set, the
message stays until it is dismissed. The attribute also takes a CSS time,
such as 5s.openbooleanWhether the message is still showing.tone"danger"|"info"|"success"|"warning"The kind of message, which sets its mark and the mark's accessible name.waitingbooleanDefaultfalseWhether the region holds the message back, because more messages are
showing than its max-visible. The region sets it. A waiting message is
hidden, its timer has not started, and it is said once it shows.
ReadTypeDescriptionwhenSettledPromise<void>Resolves a frame after the first update, when transitions are switched on.
SlotDescription(default)The message.actionsActions for the message, usually a button or a link.descriptionA line of detail under the heading, which describes the message.dismiss-iconReplaces the glyph inside the dismiss control.headingThe message's title, which names it.iconReplaces the tone mark. The name matches Callout. The dismiss control's glyph uses dismiss-icon, because two slots cannot share a name: content goes to whichever slot comes first in the tree, and the tone mark is the one you are more likely to replace.
EventTypeDescriptionhelix-dismissHelixDismissEventFired when the message is dismissed, by the control or by its timer, and cancelable. Canceling it keeps the message.
MethodTypeDescriptiondismiss() => booleanFires helix-dismiss, and returns false if a listener cancels it.pause() => voidPauses the dismiss timer and keeps the time that is left.resume() => voidRestarts the dismiss timer from where it paused.
PartDescriptionactionsThe region that holds the actions.contentThe message.descriptionThe slot the description is in. It draws no box until you give it one.dismissThe control that dismisses the message.dismiss-markThe glyph on the dismiss control, where none is slotted.headingThe slot the heading is in. It draws no box until you give it one.iconThe tone mark, where the message has one.icon-markThe tone glyph, where none is slotted.itemThe message's own surface.timerThe bar showing how long is left, where a duration was given.
CSS PropertyDescription--toast-background-colorThe panel's color. The inverse ground Tooltip draws, #f5f5f5 over a dark page and #121212 over a light one.--toast-border-colorColor of the panel's edge, once --toast-border-width gives it one.--toast-border-widthWidth of the panel's edge. 0, the opposite mode setting the panel apart from the page.--toast-colorColor of the message's text.--toast-description-colorColor of the line in the description slot, under the heading.--toast-dismiss-colorColor of the dismiss control's mark at rest.--toast-durationHow long this message stays, in milliseconds, for a progress hint.--toast-font-sizeSize of the message's text. The first line's controls and mark stay centered on it.--toast-heading-weightWeight of the heading in the heading slot.--toast-item-paddingSpace between the message's edge and its contents.--toast-radiusRounding of the panel's corners.--toast-release-durationThe longest a released message takes to go off the window, or to go back to its place. Defaults to --helix-duration-slow. 0ms lands it at once.--toast-release-easingThe curve a released message goes back to its place along. Defaults to --helix-easing-spring.--toast-shadowShadow under the panel. Follows --helix-shadow-floating. A floating surface can sit over any content, so it has a shadow by default.--toast-timer-sizeThickness of the bar that counts down a timed message.--toast-tone-colorColor of the mark and the countdown bar. Unset, each tone takes its own color, so set it per tone, as in helix-toast-item[tone="danger"].
Custom stateDescriptionclosedThe message has been dismissed and is hidden, or leaving.draggingFrom the moment a finger starts swiping the message until its release has come to rest, on screen or off it.pausedThe dismiss timer is paused, while a pointer or focus is on the message or in the stack, or while the page is hidden.settledSet one frame after the first render. Transitions wait for it, so an element does not animate its own arrival.waitingThe region holds the message back, past its max-visible, until a message before it goes.
Roothelix-headless-toastThe region that holds toast messages, and the only element that announces them.
PropTypeDescriptionfallbackLabelstringDefault"Notifications ({hotkey})"The name the element gives itself where label is empty.hotkeystringDefault"F8"The key that takes focus to the stack and back, such as F8 or Alt+T:
keys joined by +, the last one the key, as Announcement's hotkey
reads them: mod is Command on Apple devices and Control elsewhere.
Empty turns it off.hotkeyLabelstringDefault"Go to notifications"What the hotkey does, as a list of the page's shortcuts says it.labelstringDefault""Accessible name for the region, with {hotkey} filled in. Translate it with
the rest of your interface.maxVisiblenumberHow many messages show at once. The messages after that many wait, hidden
and with their timers stopped, until a message before them goes. Unset,
every message shows.placement"bottom-center"|"bottom-end"|"bottom-start"|"top-center"|"top-end"|"top-start"Which corner or edge the stack sits at.swipeDirection"bottom"|"end"|"start"|"top"The edge a touch or a pen swipes a message toward to dismiss it: end,
the end of the line, or start, top, or bottom. Unset is the inline
edge the stack sits at: start for a placement ending in start, and
end for every other.undoHintstringDefault"Press {keys} to undo."What a message undoable() made says after its own words, with {keys}
for the chord that undoes it, spoken as words.undoKeysstringDefault"mod+z"The keys that undo the newest message undoable() made, as hotkey
reads them. Empty turns them off, for an app whose own undo holds them,
and leaves the Undo button. A key the app already handled, by calling
preventDefault(), is left to it.undoLabelstringDefault"Undo"The words on the Undo button of a message undoable() made.
ReadTypeDescriptionwhenSettledPromise<void>Resolves a frame after the first update, when transitions are switched on.
SlotDescription(default)The messages.
EventTypeDescriptionhelix-dismissHelixDismissEventA message is being dismissed, by its control or by its timer. The message sends it, and you can listen for it on the region. Cancelable: canceling it keeps the message.
MethodTypeDescriptionadd(message: string, options: {
action?: Elementdismissible?: booleanduration?: numberheading?: stringtone?: "danger" | "info" | "success" | "warning"
}) => HTMLElementShows a message from script, and returns the element.undoable(message: string, options: {
commit?: () => voidduration?: numberheading?: stringtone?: "danger" | "info" | "success" | "warning"undo: () => void
}) => Promise<"kept" | "undone">Shows that an action happened and offers to undo it, which is the pattern
that replaces a confirmation dialog for an action that can be taken back.
PartDescriptionliveThe two regions that say each message as it arrives, a polite status and an assertive alert, inside the stack. Empty at rest, and hide them with the standard clip, never display: none.regionThe stack the messages are in. It is in the top layer while a message shows, and takes focus from hotkey where no message holds a control.
Custom stateDescriptionsettledSet one frame after the first render. Transitions wait for it, so an element does not animate its own arrival.
Itemhelix-headless-toast-itemOne message in the toast region.
PropTypeDescriptiondismissiblebooleanDefaultfalseWhether the element shows a control that dismisses it.dismissLabelstringDefault"Dismiss"The dismiss control's label, read by screen readers.durationnumberHow long the message stays, in milliseconds. When it is not set, the
message stays until it is dismissed. The attribute also takes a CSS time,
such as 5s.openbooleanWhether the message is still showing.tone"danger"|"info"|"success"|"warning"The kind of message, which sets its mark and the mark's accessible name.waitingbooleanDefaultfalseWhether the region holds the message back, because more messages are
showing than its max-visible. The region sets it. A waiting message is
hidden, its timer has not started, and it is said once it shows.
ReadTypeDescriptionwhenSettledPromise<void>Resolves a frame after the first update, when transitions are switched on.
SlotDescription(default)The message.actionsActions for the message, usually a button or a link.descriptionA line of detail under the heading, which describes the message.dismiss-iconReplaces the glyph inside the dismiss control.headingThe message's title, which names it.iconReplaces the tone mark. The name matches Callout. The dismiss control's glyph uses dismiss-icon, because two slots cannot share a name: content goes to whichever slot comes first in the tree, and the tone mark is the one you are more likely to replace.
EventTypeDescriptionhelix-dismissHelixDismissEventFired when the message is dismissed, by the control or by its timer, and cancelable. Canceling it keeps the message.
MethodTypeDescriptiondismiss() => booleanDismisses the message, and returns whether the dismissal went ahead.pause() => voidPauses the dismiss timer and keeps the time that is left.resume() => voidRestarts the dismiss timer from where it paused.
PartDescriptionactionsThe region that holds the actions.contentThe message.descriptionThe slot the description is in. It draws no box until you give it one.dismissThe control that dismisses the message.dismiss-markThe glyph on the dismiss control, where none is slotted.headingThe slot the heading is in. It draws no box until you give it one.iconThe tone mark, where the message has one.icon-markThe tone glyph, where none is slotted.itemThe message's own surface.timerThe bar showing how long is left, where a duration was given.
CSS PropertyDescription--toast-durationHow long this message stays, in milliseconds, for a progress hint.--toast-release-durationThe longest a released message takes to go, or to go back to its place. Unset, it lands at once.--toast-release-easingThe curve a released message goes back to its place along, with the speed it was let go carried in.
Custom stateDescriptionclosedThe message has been dismissed and is hidden, or leaving.draggingFrom the moment a finger starts swiping the message until its release has come to rest, on screen or off it.pausedThe dismiss timer is paused, while a pointer or focus is on the message or in the stack, or while the page is hidden.settledSet one frame after the first render. Transitions wait for it, so an element does not animate its own arrival.waitingThe region holds the message back, past its max-visible, until a message before it goes.
Examples
NameDescriptionAuto dismissA toast that closes on its own after eight seconds.Color modeToasts that stay in light mode, set with data-color-mode, whatever mode the page is in.EventsA message sends helix-dismiss, and your code decides whether it closes.PreviewA message over the page, in the corner set by its placement.PreviewA message over the page, in the corner set by its placement.QueueToasts stacking as they arrive, two at a time, with the next shown when you dismiss one.SwipeMessages at the bottom start of the window. Swipe one toward the start of the line to dismiss it: a quick flick from any distance, or a slow drag past halfway.ToneToasts with no tone and in the info, success, warning, and danger tones.UndoArchive a file at once, and undo it from the message, or with Command+Z, while it shows.