Toast
Temporary notifications triggered from Livewire or JavaScript.
Configuration
Blade
{{-- Add the Toast component on your main layout. --}}<body> <x-toast /></body>
Import WithTcToast trait and call the $this->toast(...) method
PHP
use Developermithu\Tallcraftui\Traits\WithTcToast; class Toast extends Component{ use WithTcToast; public function save() { $this->success(...); $this->error(...); $this->warning(...); $this->info(...); // OR $this->toast(...); }}
PHP
// Toast 1$this->toast('User created successfully'); // OR$this->success('User created successfully'); // Toast 2$this->success( title: 'User created successfully', description: 'Your changes have been saved permanently.'); // Toast 3$this->success( title: 'User created successfully', description: 'Your changes have been saved permanently.', showProgress: true); // Toast 4$this->success( title: 'User created successfully', description: 'Your changes have been saved permanently.', showCloseIcon: true);
PHP
$this->success('This is a success message');$this->warning('This is a warning message');$this->info('This is a info message');$this->error('This is a error message');
PHP
$this->success(title: 'User created successfully', position: 'top-right');$this->success(title: 'User created successfully', position: 'top-left');$this->success(title: 'User created successfully', position: 'bottom-right');$this->success(title: 'User created successfully', position: 'bottom-left');
PHP
$this->success(title: 'User created successfully', showProgress: true);
PHP
$this->success( title: 'User created successfully', redirectTo: route('docs.installation') );
Duration
By default, toasts disappear after 3 seconds. To adjust this, specify a custom duration in milliseconds using the
timeout prop.
PHP
$this->success(title: 'User created successfully', timeout: 5000);
PHP
$this->success(title: 'User created successfully', timeout: 0);
PHP
$this->success( title: 'User created successfully', description: 'Your changes have been saved permanently.' );
All available props
PHP
$this->toast( type: 'success', title: 'User created successfully', description: 'Your changes have been saved permanently', position: 'bottom-right', icon: 'check-circle', showCloseIcon: false, showProgress: false, timeout: 3000, redirectTo: '/');
Default settings
Change toast default settings according your needs config/tallcraftui.php
PHP
return [ 'toast' => [ 'position' => ToastPosition::BOTTOM_RIGHT->value, 'showCloseIcon' => false, 'showProgress' => false, 'timeout' => 3000 ],];