Repository navigation
SweetToast
Viames Marino edited this page Mar 31, 2026
·
1 revision
Pair\Html\SweetToast generates JavaScript code for SweetAlert2 toast notifications.
new SweetToast(string $title, string $message, ?string $type = 'info')Valid types: info, success, warning, error, question, progress.
The API mirrors IziToast for easier driver switching:
balloon(bool $flag)class(string $class)close(bool $flag)closeOnEscape(bool $flag)displayMode(int $mode)icon(string $icon)id(string $id)image(string $image)position(string $position)progressBar(bool $flag)theme(string $theme)timeout(int|bool $timeout)overlay(bool $flag)render(): string
Unsupported iziToast-only options are kept as compatibility no-ops when SweetAlert2 does not offer an equivalent behavior.
Configure the driver once:
$app->setToastDriver('sweetalert');Then the standard helpers automatically emit SweetAlert2 toasts:
$this->toast('Saved', 'User updated', 'success');
$this->toastError('Error', 'Unable to save user');-
SweetToastrequires SweetAlert2 to be available in the page. - Custom icon class names are rendered through SweetAlert2
iconHtml. - When no position is provided,
SweetToastuses the native SweetAlert2 default position. -
position()accepts both iziToast-style values (topRight) and SweetAlert2 aliases (top-end,bottom-start).
See also: SweetAlert, IziToast, PairUI.js, Application.
Maintained by Viames Marino — VM Ingegneria · Professional enquiries
Home · Setup · Configuration
Build with Pair 4
- Generator
- Controllers and responses
- Read models
- ActiveRecord and queries
- Forms and validation
- PairUI.js and HTML fragments
APIs and authentication
- API guide and CRUD
- Middleware and rate limits
- Users, sessions, and ACL
- Passkeys and social login
- Native mobile setup
Integrate and operate
- Integrations
- Runtime extensions and adapter keys
- Cache and cache stores
- Logs and observability
- PWA and push
- Packages and distribution
- Upgrade to v4