Toast

Material Design 3 toast notification component with native command triggers, positions, variants, and actions

Toast

Toasts provide brief, non-blocking feedback about an application process. In DuskMoonUI, .toast-container owns fixed positioning and stacking while .toast is the individual notification. This meaning is intentionally different from daisyUI and remains backward compatible.

For static HTML, make the container a manual popover and connect buttons with native command and commandfor. The browser owns open/closed rendering; DuskMoonUI supplies presentation only. Timers, queues, action execution, request state, and auto-dismiss policy remain consumer-owned.

Basic Usage

Every example on this page starts closed and is opened by a button click.

Basic Toast

This is a simple toast notification

popover="manual" avoids unrelated outside clicks dismissing a notification. Always provide an explicit close command, or use command="toggle-popover" on the trigger when the same control should both open and close it.

Container Positions

Physical left/right classes preserve their existing meaning. Prefer logical start/end classes when placement should follow text direction.

Top Positions

Top Positions

Top start notification
Top center notification
Top end notification

Bottom Positions

Bottom Positions

Bottom start notification
Bottom center notification
Bottom end notification

Semantic Variants

Use semantic color together with clear text or an icon; color must not be the only indicator.

Toast Variants

Information
New features are available
Success
Profile updated successfully
Warning
Your session will expire soon

Filled variants use the selected DuskMoon role color as the background with its matching content color. For example, .toast-filled.toast-primary uses --color-primary and --color-primary-content.

Filled Toast

Published
Your changes are now live

Actions

Application code still owns the action. The native hide command below only closes the popover after the user chooses the documented action.

Toast with Action

Update available
A new version is ready to install.

Size and Density

Toast Sizes

Small notification
Default notification
Large notification
More room for important context

Compact Toast

Saved
Compact notification style

Accent and Stacking

Combine .toast-accent with a semantic or brand color to add a thicker logical-start edge in that color. The semantic or brand class takes precedence, so the example remains a success toast instead of switching to the standalone accent color role.

Accent Toast

Success
The logical start edge carries the accent

Stacked Toasts

First notification
Second notification
Third notification

Progress Indicator

The progress bar is visual only. CSS cannot update ARIA values or dismiss the toast when the animation ends. Consumers must keep timing, announcements, and removal synchronized.

Toast with Progress

Syncing your changes

Accessibility and Lifecycle

  • Use role="status" or aria-live="polite" for ordinary confirmations and background updates.
  • Reserve role="alert" for urgent failures that require immediate attention.
  • Give every close button an accessible name.
  • Showing a pre-rendered live region may vary by assistive technology. For critical application flows, insert or update the message when the event occurs and test with the supported screen readers.
  • Native popover commands control visibility only. They do not manage queues, timers, asynchronous state, or action execution.
  • When using the legacy class API, remove closed notifications from the DOM or apply hidden/inert; opacity and transforms alone are not complete dismissal.
  • Command Invokers require browser support for command and commandfor. Consumers supporting older browsers can call showPopover()/hidePopover() from an explicit adapter without changing the markup structure.

Legacy Open-State API

Existing .toast-open, .show, and .toast-show classes remain supported for framework-managed state. Native command examples do not need these classes because .toast-container[popover]:popover-open supplies the visible state.

<div class="toast-container toast-container-top-end">
  <div class="toast toast-show" role="status">Framework-managed notification</div>
</div>

API Reference

Native Attributes

Attribute Element Purpose
popover="manual" .toast-container Keeps the fixed notification surface closed until invoked
command="show-popover" Trigger button Opens the target container
command="hide-popover" Close or action button Closes the target container
commandfor="demo-toast-*" Button References the unique container ID

Container Classes

Class Description
.toast-container Fixed positioning and stacking container
.toast-container-top-right, .toast-container-top-left Preserved physical positioning
.toast-container-bottom-right, .toast-container-bottom-left Preserved physical positioning
.toast-container-top-start, .toast-container-top-end RTL-aware top positioning
.toast-container-bottom-start, .toast-container-bottom-end RTL-aware bottom positioning
.toast-container-top-center, .toast-container-bottom-center Center positioning
.toast-container-stacked Layered presentation for multiple notifications

Toast Classes

Class Description
.toast Individual notification item
.toast-open, .show, .toast-show Preserved framework-managed visible states
.toast-primary, .toast-secondary, .toast-tertiary DuskMoon brand colors
.toast-info, .toast-success, .toast-warning, .toast-error Semantic colors
.toast-filled, .toast-ghost Surface variants
.toast-sm, .toast-lg, .toast-compact Size and density variants
.toast-accent Logical-start accent edge
  • Alert — persistent inline feedback
  • Snackbar — action-oriented transient messaging with its existing API
  • Popover — general-purpose interactive overlay content