RizzyUI

RzToastProvider

RzToastProvider is the SSR-only root provider for toast notifications. It owns the toast viewport, renders the position stacks, and publishes the server-generated class map consumed by the Rizzy.toast JavaScript runtime.

Developers do not manually render toast items. Add one provider, then create toasts by calling Rizzy.toast or dispatching rz:toast events from client code, HTMX fragments, or other SSR-safe flows.

Installation / Root Layout Placement

In an application, place one provider near the root layout, typically after @Body. The provider renders all supported stacks up front; Position only controls the default stack for requests that do not provide a position.

Root layout
@inherits LayoutComponentBase

<div class="min-h-screen">
    @Body
</div>

<RzToastProvider />
Documentation page demo provider
<RzToastProvider Id="docs-toast-provider"
                 Position="ToastPosition.TopRight"
                 MaxVisible="5"
                 ShowProgress="true" />

Server-triggered toasts with Rizzy

AddRizzyUI() registers the scoped IRzToastService and the internal ordered command queue. Add UseRzToast() to the request pipeline so commands queued during an HTMX request are emitted as one rz:toast:batch HX-Trigger event. The root layout must still render one RzToastProvider; the service only transports commands to the existing browser runtime.

Program setup
builder.Services.AddRizzy();
builder.Services.AddRizzyUI();

var app = builder.Build();

app.UseRizzy();
app.UseRzToast();

app.MapControllers();
app.MapRazorComponents<App>();

The C# API mirrors the server-compatible Rizzy.toast methods: Show, Custom, Success, Error, Warning, Info, Loading, Update, Dismiss, and Clear. Commands keep their insertion order in the batch, so a show followed by an update for the same stable id is processed in that order by the browser.

Success from an HTMX endpoint
public IActionResult Save([FromServices] IRzToastService toastService)
{
    toastService.Success("Project settings saved.", "Saved");
    return View();
}
Equivalent JavaScript
Rizzy.toast.success("Project settings saved.", "Saved");
Custom show and stable id
toastService.Show(new RzToastMessage
{
    Status = ToastStatus.Warning,
    Title = "Session expiring",
    Text = "Your session expires in two minutes.",
    Position = ToastPosition.BottomRight,
    Duration = 7000,
    DedupeKey = "session-expiration"
});

var handle = toastService.Loading("Uploading file...", "Uploading", new RzToastOptions
{
    Id = "profile-photo-upload"
});

handle.Update(new RzToastUpdate
{
    Status = ToastStatus.Success,
    Title = "Uploaded",
    Text = "Your profile photo was updated.",
    AutoClose = true,
    Duration = 3000,
    Progress = true
});
Update, dismiss, clear, and event action
toastService.Update("profile-photo-upload", new RzToastUpdate
{
    Status = ToastStatus.Success,
    Title = "Uploaded",
    Text = "Your profile photo was updated."
});

toastService.Dismiss("obsolete-toast");
toastService.Dismiss();
toastService.Clear();

toastService.Success("Message archived.", "Archived", new RzToastOptions
{
    Action = new RzToastAction
    {
        Label = "Undo",
        EventName = "rz:message:restore",
        Detail = new { MessageId = 42 }
    }
});

Live Examples

These examples use delegated documentation event listeners and stable data-rz-toast-demo attributes. The buttons call the real Rizzy.toast facade in the same DOM context as the provider above.

Default toast

Use a default toast for neutral feedback that confirms an operation completed or provides lightweight status information.

Source
Rizzy.toast.show({
    title: "Notification",
    description: "The background check completed."
});

Title and description

Use a title when the toast needs a scannable heading and a short supporting message.

Source
Rizzy.toast.info("The report is being generated. You can continue working.", "Report started");

Success toast

Use a success toast after a save, publish, upload, or completed background operation.

Source
Rizzy.toast.success("Project settings saved.", "Saved");

Info toast

Use an info toast for non-critical status updates, background task starts, or contextual notices.

Source
Rizzy.toast.info("Build started. You can continue working while it runs.", "Build started");

Warning toast

Use a warning toast for non-blocking conditions the user may need to notice soon.

Source
Rizzy.toast.warning("Your session expires in 2 minutes.", "Session expiring");

Error toast

Use an error toast when an operation fails but the user can continue working. For blocking failures, use an alert, dialog, or form validation message instead.

Source
Rizzy.toast.error("Unable to upload image. Check the file type and try again.", "Upload failed");

Action toast

Use an action toast when the user can immediately recover from the event, such as undoing a delete or retrying a failed operation.

Source
Rizzy.toast.success("Message archived.", "Archived", {
    action: {
        label: "Undo",
        dismissOnClick: true,
        onClick: toast => {
            Rizzy.toast.info("The message was restored.", "Undo complete");
            toast.dismiss();
        }
    }
});

Persistent toast

Use a persistent toast for progress or status that should remain visible until the user dismisses it or code updates it.

Source
Rizzy.toast.info("Waiting for the background worker to respond.", "Still working", {
    autoclose: false,
    progress: false
});

Custom duration

Use a custom duration when the message needs slightly more or less reading time than the provider default.

Source
Rizzy.toast.success("Export completed and is ready to download.", "Export ready", {
    duration: 7000
});

Loading and update flow

Use a loading toast for long-running work, then update the same id when the operation completes.

Source
Rizzy.toast.loading("Uploading changes...", "Syncing", {
    id: "docs-loading-demo"
});

setTimeout(() => {
    Rizzy.toast.update("docs-loading-demo", {
        status: "success",
        title: "Synced",
        text: "All changes are online.",
        autoclose: true,
        duration: 3000,
        progress: true
    });
}, 1500);

Positioning

RzToastProvider renders separate stacks for every supported position, so different toast requests can appear in different regions at the same time.

Source
Rizzy.toast.info("This toast appears in the top-right stack.", "Top right", {
    position: "top-right"
});

Rizzy.toast.info("This toast uses the Simple Notify alias bottom left.", "Bottom left", {
    position: "bottom left"
});

Rizzy.toast.info("This toast appears in the center stack.", "Center", {
    position: "center"
});

Rizzy.toast.info("This toast uses the Simple Notify alias right y-center.", "Right center", {
    position: "right y-center"
});

Programmatic dismiss and clear

Use a stable id when you need to dismiss or update a specific toast later. Use clear when a context change makes existing notifications irrelevant.

Source
Rizzy.toast.info("This toast can be dismissed by id.", "Tracked toast", {
    id: "docs-dismiss-demo",
    autoclose: false,
    progress: false
});

Rizzy.toast.dismiss("docs-dismiss-demo");

Rizzy.toast.clear();

Event dispatch

Use rz:toast events when a server-rendered fragment, HTMX response, or other client code needs to publish a toast without directly calling the facade.

Show event
window.dispatchEvent(new CustomEvent("rz:toast", {
    detail: {
        id: "docs-event-demo",
        status: "success",
        title: "Saved",
        description: "The event API created this toast."
    }
}));
Update, dismiss, and clear events
window.dispatchEvent(new CustomEvent("rz:toast:update", {
    detail: {
        id: "docs-event-demo",
        text: "The event API updated this toast."
    }
}));

window.dispatchEvent(new CustomEvent("rz:toast:dismiss", {
    detail: { id: "docs-event-demo" }
}));

window.dispatchEvent(new CustomEvent("rz:toast:clear"));

Dedupe behavior

Use dedupeKey for one logical notification that may update repeatedly instead of stacking duplicates.

Press repeatedly to update/coalesce the same logical warning.

Source
Rizzy.toast.show({
    dedupeKey: "docs-storage-warning",
    status: "warning",
    title: "Storage warning",
    text: "Storage is still almost full.",
    incrementCount: true
});

Stacking and overflow

MaxVisible limits the number of visible toasts per position stack. The default overflow strategy dismisses the oldest toast in the affected stack.

Source
for (let index = 1; index <= 7; index += 1) {
    Rizzy.toast.info(`Stacked notification ${index}`, "Stack demo", {
        position: "bottom-right",
        duration: 8000
    });
}

Usage Guidelines

Use toast notifications for

  • Save confirmations
  • Background task completion
  • Non-blocking errors
  • Short status messages
  • Undo or retry actions

Avoid toast notifications for

  • Required decisions
  • Field-level validation
  • Blocking errors
  • Long explanations
  • Multi-step workflows

Use RzAlert for persistent inline feedback, a dialog for required decisions, and form validation messages near the related field.

API Reference

Provider Parameters

PropertyDescriptionTypeDefault
PositionDefault stack for new toasts; all stacks are still rendered.ToastPositionToastPosition.TopRight
DefaultStatusDefault semantic status for new toasts.ToastStatusToastStatus.Info
ToneDefault visual tone.ToastToneToastTone.Subtle
AnimationDefault animation preset.ToastAnimationToastAnimation.Fade
OverflowStrategyBehavior when a stack reaches MaxVisible.ToastOverflowStrategyDismissOldest
DurationDefault auto-dismiss duration in milliseconds.int4000
SpeedLeaving transition speed in milliseconds.int300
MaxVisibleMaximum visible toast count per position stack.int5
NewestOnTopWhether new toasts insert before older toasts.booltrue
DismissibleWhether close buttons render by default.booltrue
ShowIconWhether status icons render by default.booltrue
ShowProgressWhether progress indicators render by default.booltrue
PauseOnHoverWhether timers pause during pointer hover.booltrue
PauseOnFocusWhether timers pause while focus is inside a toast.booltrue
PauseOnWindowBlurWhether timers pause while the window is blurred.boolfalse
CloseOnEscapeWhether Escape dismisses a focused toast.booltrue
PreventDuplicatesWhether duplicate requests update instead of stacking.boolfalse
CloseButtonAriaLabelAccessible label for close buttons.string?localized
RegionAriaLabelAccessible label for the provider region.string?localized

Toast Request Options

OptionDescriptionTypeDefault
idStable id for update or dismiss.stringgenerated
statusCanonical toast status.stringprovider default
variantAlias for status.stringnone
titleScannable heading text.stringempty
textPrimary description text.stringempty
messageAlias for text.stringnone
descriptionAlias for text.stringnone
positionCanonical position or supported alias.stringprovider default
durationAuto-dismiss time in milliseconds.numberprovider default
autotimeoutAlias for duration.numbernone
autocloseWhether the toast closes automatically.booleanduration > 0
toneVisual tone.stringprovider default
typeAlias for tone; filled maps to solid.stringnone
animationAnimation preset.stringprovider default
effectAlias for animation.stringnone
dismissibleWhether the close button is shown.booleanprovider default
showCloseButtonAlias for dismissible.booleannone
actionAction button label and JavaScript callback.objectnone
dedupeKeyLogical key used to update instead of stack.stringnone
incrementCountIncrement coalesced toast count.booleanfalse
dataSerializable data forwarded to lifecycle events.anynone
customClassAlias for root toast class.stringnone
classNameAlias for root toast class.stringnone
classNamesSlot-specific class overrides.object{}

Statuses

StatusUseARIADefault tone
defaultNeutral feedback.status / politesubtle
infoNon-critical status updates.status / politesubtle
successCompleted operations.status / politesubtle
warningNon-blocking concerns.status / politesubtle
errorRecoverable failures.alert / assertivesubtle
loadingLong-running work.status / politesubtle

Positions

Canonical valueSimple Notify-compatible aliasesRegionNotes
top-leftleft top, top leftTop leftCanonical corner stack.
top-centertop center, center top, x-center top, top x-centerTop centerCentered along top edge.
top-rightright top, top rightTop rightDefault provider position.
bottom-leftleft bottom, bottom leftBottom leftSimple Notify alias supported.
bottom-centerbottom center, center bottom, x-center bottom, bottom x-centerBottom centerCentered along bottom edge.
bottom-rightright bottom, bottom rightBottom rightUseful for stack demos.
centercenterCenterCentered viewport stack.
left-centerleft center, left y-center, y-center leftLeft centerVertical center alias supported.
right-centerright center, right y-center, y-center rightRight centerVertical center alias supported.

Overflow Strategies

EnumRequest valueBehaviorUse when
DismissOldestdismiss-oldestDismisses the oldest toast in the affected stack.New information should still appear.
IgnoreNewestignore-newestDrops the newest request when the stack is full.Existing notifications are more important.

Accessibility

Toasts do not steal focus. The provider root exposes a named region, while each JavaScript-rendered toast announces through live-region semantics instead of moving the user away from their current task.

Default, info, success, warning, and loading toasts use role="status" with aria-live="polite". Error toasts use role="alert" with aria-live="assertive". Every toast uses aria-atomic="true" so assistive technology announces the complete message.

Close controls are native buttons with accessible labels, action buttons are keyboard reachable, and Escape can dismiss a focused toast when CloseOnEscape is enabled. Auto-dismiss timers pause on hover and focus when configured, helping users read or act on content before it disappears.

Give users enough time for toast content, avoid long or critical messages, and never make a toast the only way critical information is communicated. Reduced-motion preferences are respected through the generated class map, and functional timing does not depend on animation.

Theming

Provider and toast item classes come from Theme.RzToastProvider. JavaScript reads the class map rendered by the provider and applies slot, status, tone, animation, state, and position classes without constructing Tailwind class strings at runtime.

Override the descriptor in your theme to adjust the provider root, viewport stacks, toast item slots, status variants, tones, animations, and reduced-motion-safe states.

CSP Notes

The toast runtime is loaded through the normal RizzyUI JavaScript entries, including the CSP-safe entry. It avoids eval, new Function, inline event handlers, dynamic script injection, and runtime Tailwind construction.

This documentation page uses a CSP-safe delegated listener in /js/site.js. Toast text is assigned as text content by the runtime; HTML content must be supplied as a trusted HTMLElement.

Migration Notes

The public Rizzy.toast facade preserves compatibility helpers such as success, error, warning, info, custom, and Simple Notify option aliases including variant, message, description, autotimeout, effect, type, customClass, and compatible position strings.

Simple Notify CSS class names are not preserved. Style toast output through Theme.RzToastProvider and the provider-generated class map.

Troubleshooting

No toast appears

Ensure RzToastProvider is rendered on the current page or root layout and that the RizzyUI JavaScript runtime is loaded before calling Rizzy.toast.

Toast does not work inside RzBrowser

RzBrowser renders its inner content in an iframe. Place the provider directly on the page or in the application layout, not inside browser preview components.

Toast appears in the wrong position

Use canonical positions such as top-right or bottom-left, or one of the supported Simple Notify aliases such as bottom left or right y-center.

Toast disappears too quickly

Increase Duration or request-level duration, set autoclose to false for persistent toasts, and keep PauseOnHover or PauseOnFocus enabled when users may need more time.

Action button does not run

Action callbacks must be real JavaScript functions. Runtime callback errors are caught and logged to the console.

Styles look wrong or missing

Classes come from the provider’s server-generated class map and Theme.RzToastProvider. Make sure the provider renders and the Tailwind build includes RizzyUI descriptor classes.