Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Search API HTML Element Filter 1.0.7 Minor update available for module search_api_html_element_filter (1.0.7). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). UI Patterns (SDC in Drupal UI) 2.0.18 Minor update available for module ui_patterns (2.0.18). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

Advanced Toast Messages

43 sites No security coverage
View on drupal.org

This module provides a modern and flexible toast notification system using Single Directory Components. It allows for non-intrusive, temporary messages that can be triggered from PHP, Twig, or JavaScript. You can also extend it with custom toast types per theme and optionally replace standard Drupal messages with toasts.

A modern, flexible toast notification system for Drupal 10.3+ and Drupal 11 built on Single Directory Components (SDC).

Motivation

Traditional Drupal messages appear at the top of the page, requiring users to scroll up to see feedback after form submissions or actions. Toast notifications solve this by displaying temporary, non-intrusive messages that appear in a fixed position (like bottom-right corner), providing immediate feedback without disrupting the user's workflow.

This module was created to provide a component-based toast system that:

  • Integrates seamlessly with Drupal's SDC architecture
  • Allows complete theming control without touching module code
  • Supports extending with custom toast types per theme
  • Provides multiple APIs (PHP, Twig, JavaScript) for maximum flexibility
  • Works alongside or replaces standard Drupal messages

Key Features

  • Module-based components - Includes status, warning, and error toasts out of the box
  • Theme extensibility - Create custom toast types in your theme (e.g., info, celebration, success)
  • Multiple APIs - Trigger toasts from PHP services, Twig templates, or JavaScript
  • Drupal message replacement - Optionally convert standard Drupal messages to toasts globally
  • Three-tier fallback system - Ensures toasts always render even if custom components are missing
  • Configurable admin UI - Map unlimited toast types to components with validation
  • Accessible - ARIA live regions, keyboard support, respects prefers-reduced-motion
  • Server-side rendering - Components render server-side for SEO and accessibility
  • Template inheritance - Custom components can extend base toast templates
  • Cache-friendly lazy rendering - Toasts render via lazy builders (like Drupal core's status messages), allowing pages to be fully cached while toast content remains session-specific

Simple Example

From PHP

$toast = \Drupal::service('advanced_toast.toast');

// Standard toasts
$toast->status('Your changes have been saved!');
$toast->warning('Please review your submission.');
$toast->error('An error occurred.');

// Custom toast with options
$toast->addToast('Welcome!', 'info', [
  'duration' => 3000,
  'fallback' => 'status',
]);

From Twig

{{ toast_status('Your changes have been saved!') }}
{{ toast_warning('Please review your submission.') }}
{{ toast_error('An error occurred.') }}

From JavaScript

Drupal.toast('Your changes have been saved!', 'status');
Drupal.toast('Please review your submission.', 'warning');

Creating Custom Toast Types

Easily extend with theme-specific toasts:

# themes/custom/mytheme/components/toast-celebration/toast-celebration.component.yml
name: Toast Celebration
thirdPartySettings:
  advanced_toast:
    is_toast_component: true
props:
  type: object
  properties:
    message:
      type: string
  required:
    - message

Map the component at /admin/config/user-interface/toast and use it:

$toast->addToast('🎉 Achievement unlocked!', 'celebration');

Use Cases

  • Better UX - Non-intrusive feedback that doesn't require scrolling
  • Modern interfaces - Match contemporary web application patterns
  • Custom notifications - Create celebration toasts with confetti, promotional toasts, achievements, etc.
  • Multi-theme sites - Each theme can define its own toast styles and types
  • Consistent feedback - Standardize all user feedback across your application

Requirements

  • Drupal 10.3+ or Drupal 11+
  • Single Directory Components (SDC) module (included in core)

Documentation

For complete documentation including:

  • Configuration guide
  • Creating custom toast types
  • Theme customization examples
  • API reference
  • Troubleshooting

See the README.md in the project repository.

Installation

composer require drupal/advanced_toast
drush en advanced_toast
drush cr

Configuration

Visit /admin/config/user-interface/toast to:

  • Enable Drupal message replacement
  • Configure default duration and position
  • Map toast types to SDC components
  • Add custom toast types

Credits

Co-authored with Claude Code - AI pair programming assistant by Anthropic.

Activity

Total releases
4
First release
Nov 2025
Latest release
6 months ago
Releases (12 mo)
4 ▲ from 0
Maintenance
Slowing

Release Timeline

Releases

Version Type Release date
1.0.3 Stable Jan 5, 2026
1.0.2 Stable Dec 11, 2025
1.0.1 Stable Nov 28, 2025
1.0.0 Stable Nov 27, 2025