Toast

µToast is a fixed-position notification wrapper. It uses the existing alert component for content styling and adds 6 positioning options.

Basic usage

Wrap an .alert inside a .toast container with a position class:

<div class="toast toast-top-right">
    <div class="alert alert-success" role="alert">
        <p>Changes saved.</p>
    </div>
</div>

Positions

6 position classes are available:

<div class="toast toast-top-right">...</div>
<div class="toast toast-top-left">...</div>
<div class="toast toast-top-center">...</div>
<div class="toast toast-bottom-right">...</div>
<div class="toast toast-bottom-left">...</div>
<div class="toast toast-bottom-center">...</div>
Class Placement
.toast-top-righttop: 1rem; right: 1rem
.toast-top-lefttop: 1rem; left: 1rem
.toast-top-centertop: 1rem; left: 50%; transform: translateX(-50%)
.toast-bottom-rightbottom: 1rem; right: 1rem
.toast-bottom-leftbottom: 1rem; left: 1rem
.toast-bottom-centerbottom: 1rem; left: 50%; transform: translateX(-50%)

Color variants

Toasts reuse the alert color variants. All 11 color roles are available:

<div class="toast toast-top-right">
    <div class="alert alert-primary" role="alert"><p>Primary toast.</p></div>
</div>

<div class="toast toast-top-right">
    <div class="alert alert-error" role="alert"><p>Error toast.</p></div>
</div>

Available variants: alert-primary, alert-secondary, alert-tertiary, alert-contrast, alert-accent, alert-success, alert-info, alert-warning, alert-error, alert-pop, alert-spark.

With title

Use .alert-title for a bold heading inside the toast:

<div class="toast toast-top-right">
    <div class="alert alert-success" role="alert">
        <span class="alert-title">Saved!</span>
        <p>Your changes have been saved.</p>
    </div>
</div>

Dismissible

Add .alert-dismissible and an .alert-close button:

<div class="toast toast-top-right">
    <div class="alert alert-info alert-dismissible" role="alert">
        <p>This toast can be dismissed.</p>
        <button class="alert-close" aria-label="Close" onclick="this.closest('.toast').remove()">&times;</button>
    </div>
</div>

CSS classes reference

Class Description
.toastFixed-position wrapper (position: fixed, z-index: 1050, max-width: 350px)
.toast-top-rightPosition top-right
.toast-top-leftPosition top-left
.toast-top-centerPosition top-center
.toast-bottom-rightPosition bottom-right
.toast-bottom-leftPosition bottom-left
.toast-bottom-centerPosition bottom-center

Responsive behavior

On viewports narrower than 640px, all toast positions switch to full-width (left: 1rem; right: 1rem; max-width: none) to avoid content overflow on mobile devices.

Styling details

Property Value
Positionfixed
Z-index1050
Max-width350px (none on mobile)
Spacing from edge1rem

Accessibility

  • Use role="alert" on the inner alert element so screen readers announce the notification.
  • Dismissible toasts should include aria-label="Close" on the close button.
  • Auto-dismiss timing (e.g. 4 seconds) is the application's JS responsibility — µCSS provides only the CSS positioning.

See also: Alert