Getting startedComponentsDesign tokensThemingTheme synthesizerFrameworksAccessibilityUtilitiesServer renderingBrowser supportContributingChangelogApp ShellAspect GridAuth ShellCenterContainerDashboard GridFloat BarInsetMasonryPage HeaderPage LayoutResizableResponsive SwitcherSectionSettings LayoutSplit PaneStatus BarStickyToolbarAnchor NavBottom NavBreadcrumbBreadcrumb MenuCommand BarDrawerFooterLinkMenubarNavigation MenuPage IndicatorPaginationRailScroll IndicatorScroll SpyScroll To TopSidebarSkip LinkStepper NavTabsTop BarTree ViewAccordionAspect RatioAvatarAvatar GroupCardCarouselCollapsibleColor SwatchCTA BannerDividerEmpty StateFeature CardIconImageImage CompareImage HotspotsInfinite ScrollLightboxMarqueeQR CodeScroll AreaSkeletonSpinnerStackVideoVirtual ListActivity HeatmapAnimated NumberBadgeBar ListChartClockComparisonCountdown TimerData GridDescription ListDiffGaugeJSON TreeKanbanLevel MeterListMeterSparklineStatStepperTagTimelineUptimeValue CardWaveformBlockquoteCode BlockCode GroupGradient TextHighlightKbdKeyboard MapMarkdownNumber FormatProseTerminalTextTime AgoTruncateTypewriterButtonButton GroupCalendarCheckboxChipColor PickerComboboxCopy ButtonDate PickerDate Range PickerField ListFieldsetFile UploadFormHotkeyIcon ButtonImage CropperInline EditInputInput GroupKnobLabelMasked InputMulti SelectNumber InputPassword InputPin InputRadio GroupRange SliderRatingSearchSegmented ControlSelectSignature PadSliderSortable ListSwitch GroupTag InputTextareaTheme ToggleTime PickerToggleTransfer ListTree SelectAlertAnnouncementBannerCommand PaletteConfirmConnection StatusContext MenuConversationDialogDropdown MenuHover CardLoading OverlayNotification PanelPopoverProgressSheetToastTooltip
ARC UIARC Radiant Components
v4.9DocsComponentsTokensSynthesizer
Getting startedFrameworksServer renderingDesign tokensThemingTheme synthesizerTypographyUtilitiesAll componentsAccessibilityBrowser supportChangelogContributingStatsApp ShellAspect GridAuth ShellCenterContainerDashboard GridFloat BarInsetMasonryPage HeaderPage LayoutResizableResponsive SwitcherSectionSettings LayoutSplit PaneStatus BarStickyToolbarAnchor NavBottom NavBreadcrumbBreadcrumb MenuCommand BarDrawerFooterLinkMenubarNavigation MenuPage IndicatorPaginationRailScroll IndicatorScroll SpyScroll To TopSidebarSkip LinkStepper NavTabsTop BarTree ViewAccordionAspect RatioAvatarAvatar GroupCardCarouselCollapsibleColor SwatchCTA BannerDividerEmpty StateFeature CardIconImageImage CompareImage HotspotsInfinite ScrollLightboxMarqueeQR CodeScroll AreaSkeletonSpinnerStackVideoVirtual ListActivity HeatmapAnimated NumberBadgeBar ListChartClockComparisonCountdown TimerData GridDescription ListDiffGaugeJSON TreeKanbanLevel MeterListMeterSparklineStatStepperTagTimelineUptimeValue CardWaveformBlockquoteCode BlockCode GroupGradient TextHighlightKbdKeyboard MapMarkdownNumber FormatProseTerminalTextTime AgoTruncateTypewriterButtonButton GroupCalendarCheckboxChipColor PickerComboboxCopy ButtonDate PickerDate Range PickerField ListFieldsetFile UploadFormHotkeyIcon ButtonImage CropperInline EditInputInput GroupKnobLabelMasked InputMulti SelectNumber InputPassword InputPin InputRadio GroupRange SliderRatingSearchSegmented ControlSelectSignature PadSliderSortable ListSwitch GroupTag InputTextareaTheme ToggleTime PickerToggleTransfer ListTree SelectAlertAnnouncementBannerCommand PaletteConfirmConnection StatusContext MenuConversationDialogDropdown MenuHover CardLoading OverlayNotification PanelPopoverProgressSheetToastTooltip

Toast

Short messages that stack at one edge of the screen and dismiss themselves.

ComponentsToast
feedbackinteractive
<arc-toast>

Overview

Toast shows short messages that don't block the page and dismiss themselves, such as "File saved" or "Back online". Place one `<arc-toast>` in your layout and call its `show()` method whenever a message should appear. Toasts stack at one corner or edge of the viewport, set by `position`, and span the full width below 640px. `max-visible` (3 by default) caps how many are on screen. The rest wait in a queue, up to `queue-limit`, and appear as space frees up. Set `max-visible="0"` for no cap. Dedupe is on by default. Showing a message that matches a visible or queued toast of the same variant adds a "(×N)" counter to that toast and restarts its timer, in place, with no second toast. Set `no-dedupe` to turn it off. To raise a toast without a reference to the element, dispatch an `arc-toast` event on `document` with the options `show()` takes. For long-running work, pass a numeric `progress` to `show()`. The toast draws a track under its message, is never deduped and never dismisses on a timer, so two uploads with the same file name get two bars. Move the bar with `updateToast(id, { progress })` and finish with `complete(id)`. That dismisses the toast and fires `arc-complete`. `complete` is separate from `dismiss` so that code waiting for the work to finish doesn't run when the reader closes the toast. An `onCancel` callback turns the close button into a cancel button that fires `arc-cancel`. Progress mode is set at `show()` and can't be turned on later. `actionLabel` adds a button for an undo or a retry. Clicking it runs the `action` callback, fires `arc-action` and dismisses the toast.

Guidelines

Do

  • Place one `<arc-toast>` at the root of your layout so every page shares it
  • Use `success` to confirm saves, uploads and deletions
  • Keep messages to one sentence so readers finish before the toast goes
  • Use `error` for failures that need acknowledging but not a blocking dialog
  • Set `duration` to 0 for a message the reader must close
  • Use progress mode for work with a known percentage, such as uploads, exports and batch jobs
  • Give a progress toast `onCancel` only when the work can really be stopped
  • Call `complete(id)` when the work finishes

Don't

  • Don't use a toast for anything that needs a decision or input. Use Dialog, or Confirm for a yes or no
  • Don't show passwords, tokens or other secrets. Anyone nearby can see them
  • Don't set a duration under 2000ms. Readers may not finish the message
  • Don't rely on color alone. The icon and the text must carry the meaning
  • Don't fire one toast per item in a batch. Summarize the batch in one
  • Don't use progress mode for work of unknown length. Use Spinner
  • Don't leave a progress toast open after the work ends. It never dismisses itself, so call `complete(id)` or `dismiss(id)`
  • Don't make an action button the only way to reach an irreversible action. The toast dismisses on its own

Features

  • `show({ message, variant, duration })` returns the toast's id, and `dismiss(id)` removes it whether it's visible or queued
  • `duration` defaults to 4000ms, and 0 keeps a toast until it's closed
  • Positions: `top-right`, `top-left`, `top-center`, `bottom-right`, `bottom-left` and `bottom-center`
  • Four variants (info, success, warning and error), each with an icon and a colored bottom edge
  • `updateToast()` can change the message in the same call as the progress
  • `arc-queue-change` reports the visible and queued counts, and `arc-queue-overflow` fires when the queue is full and the oldest waiting toast is dropped
  • `arc-close` fires with the toast's id when it's removed
  • The container has `role="status"` and `aria-live="polite"`, so screen readers announce new messages without moving focus

Preview

Show success toastShow error toastUpload a file

Usage

This component needs JavaScript. Use the Web Component or a framework wrapper.

<script type="module" src="@arclux/arc-ui"></script>

<arc-toast id="toaster" position="top-right"></arc-toast>

<div style="display: flex; gap: 8px; flex-wrap: wrap;">
  <arc-button variant="primary"
    onclick="document.getElementById('toaster').show({ message: 'Changes saved successfully.', variant: 'success' })">
    Success
  </arc-button>
  <arc-button variant="secondary"
    onclick="document.getElementById('toaster').show({ message: 'Something went wrong.', variant: 'error' })">
    Error
  </arc-button>
  <arc-button variant="ghost"
    onclick="document.getElementById('toaster').show({ message: 'Deployment in progress...', variant: 'warning', duration: 6000 })">
    Warning (6 s)
  </arc-button>
  <arc-button variant="ghost" onclick="upload()">Upload</arc-button>
</div>

<script>
  // Progress mode: a numeric progress option renders the track. The toast then
  // skips dedupe and never auto-dismisses — it ends when complete() says so.
  async function upload() {
    const toaster = document.getElementById('toaster');
    const controller = new AbortController();
    const id = toaster.show({
      message: 'Uploading report.pdf…',
      progress: 0,
      onCancel: () => controller.abort(),   // this is what renders the cancel button
    });

    try {
      for (let sent = 0; sent <= 100; sent += 10) {
        await sendChunk(sent, { signal: controller.signal });
        toaster.updateToast(id, { progress: sent });
      }
      toaster.updateToast(id, { message: 'Uploaded report.pdf' });
      toaster.complete(id);                 // dismisses and fires arc-complete
    } catch {
      toaster.dismiss(id);
      toaster.show({ message: 'Upload failed.', variant: 'error' });
    }
  }

  // Completion and cancellation are distinct events, so a listener can tell
  // "the work finished" from "the user closed it".
  document.getElementById('toaster').addEventListener('arc-complete', (e) => {
    console.log('upload finished', e.detail.id);
  });
</script>

API

durationnumber4000
Time in milliseconds before a toast auto-dismisses. Applies as the default for every show() call but can be overridden per-toast via the duration option in the show() payload. Set to 0 to disable auto-dismiss entirely, requiring the user to click the close button.
max-visiblenumber3
Maximum toasts on screen at once (attribute: max-visible). Further show() calls queue FIFO and release as visible toasts dismiss. Set to 0 for no cap.
position'top-right' | 'top-left' | 'top-center' | 'bottom-right' | 'bottom-left' | 'bottom-center''top-right'
Anchors the toast stack to a fixed edge of the viewport. Top-right is the most conventional position for web applications. Bottom positions work well for media players or editors where the top area is occupied by toolbars.
dedupebooleantrue
When true, a show() whose message and variant match a visible or queued toast is coalesced: the existing toast gains a "(×N)" counter and a fresh timer instead of a second toast appearing. Set the property to false from JS to disable.
queueLimitnumber20
Maximum queued (not visible) toasts (attribute: queue-limit). Beyond it the oldest queued entries are dropped and arc-queue-overflow fires with the drop count.

Methods

show(options?)options?: { id?: number|string, message?: string, variant?: 'info' | 'success' | 'warning' | 'error', duration?: number, persistent?: boolean, progress?: number, action?: () => void, actionLabel?: string, onCancel?: () => void }number|string
Show a toast, or coalesce it into an identical one that is already showing. Passing progress puts the toast in progress mode, absorbed from arc-progress-toast in 4.2: it renders a track beneath the message, exempts itself from dedupe and from the auto-dismiss timer, and, given onCancel, offers a cancel button that fires arc-cancel. Move the bar with updateToast(id, { progress }) and end it with complete(id), which fires arc-complete. The mode is chosen here and is not switchable afterwards: a track appearing mid-life would relayout a notification the reader is already reading. action and actionLabel arrive from arc-snackbar the same way. The label renders a ghost button; a click runs the callback and fires arc-action before the toast dismisses.
dismiss(id)id: number|string
Dismiss a toast by the id show() returned, whether it is visible or still queued. Unknown ids are ignored.
clear()
Dismiss everything on screen and discard the queue.
updateToast(id, changes)id: number|string, changes: { progress?: number, message?: string }
Move a progress toast's bar, its message, or both. Unknown ids are ignored, matching dismiss(). Named updateToast rather than update because update is Lit's. It is the name arc-progress-toast used, and the reason that component carried a do-nothing update(changedProps) { super.update(changedProps); } override that read as if it meant something.
complete(id)id: number|string
Finish a progress toast: dismiss it and fire arc-complete. Distinct from dismiss() on purpose: the operation finishing and the user closing the toast are different events, and a consumer waiting on the first should not be woken by the second.

Events

arc-queue-overflow
Fired when the queue exceeds queueLimit and the oldest queued entries are dropped. detail: { dropped }.
arc-queue-change
Fired whenever the visible or queued count changes. detail: { visible, queued }.
arc-complete
Fired when a progress toast is completed with complete(id). detail: { id }.
arc-cancel
Fired when the user clicks a progress toast's cancel button. detail: { id }.
arc-action
Fired when the user clicks a toast's action button, before it dismisses. detail: { id }. Absorbed from arc-snackbar, whose action was reachable as an event as well as the action callback; a callback cannot be attached declaratively.
arc-close
Fired when a toast notification is dismissed. detail: { id }, the id show() returned.

See also