Drupal is a registered trademark of Dries Buytaert
Release: Excel Serialization 2.1.2 Minor update available for module xls_serialization (2.1.2). Release: Time Zone Field 8.x-1.14 Minor update available for module tzfield (8.x-1.14). Module Revived: Entity API 8.x-1.7 Module entity updated after 17 months of inactivity (8.x-1.7). Release: Varbase - The Ultimate Drupal CMS Starter Kit (Bootstrap Ready) 10.1.2 Minor update available for distribution varbase (10.1.2). Release: MCP Sentinel 2.8.0 Minor update available for module mcp_sentinel (2.8.0). Release: Vartheme Bs5 4.1.1 Minor update available for theme vartheme_bs5 (4.1.1). Release: Varbase Heroslider 1.1.3 Minor update available for module varbase_heroslider (1.1.3). Release: Varbase Demo 1.1.2 Minor update available for module varbase_demo (1.1.2). Release: Varbase Dashboards 2.0.3 Minor update available for module varbase_dashboards (2.0.3). Security Coverage: Role Aware Maxlength Module role_aware_maxlength now has official Drupal security advisory coverage.

Advanced Toast Messages

51 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

Tracked releases
4
Tracked since
Nov 2025
Latest release
7 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