realrashid/sweet-alert
Laravel package to integrate SweetAlert2 popups: stylish alerts, confirmations, toasts, and notifications. Trigger from controllers or views with simple helpers and session flashes, customize options, and improve UX with minimal setup.
persistent($showConfirmBtn = true, $showCloseBtn = false)
// example:
alert()->success('SuccessAlert','Lorem ipsum dolor sit amet.')->persistent(true,false);
autoClose($milliseconds = 5000)
// example:
toast('Success Toast','success')->autoClose(5000);
position($position = 'top-end')
Modal window and Toast position, can be 'top', 'top-start', 'top-end', 'center', 'center-start', 'center-end', 'bottom', 'bottom-start', or 'bottom-end'.
// example:
alert('Title','Lorem Lorem Lorem', 'success')->position('top-end');
showConfirmButton($btnText = 'Ok', $btnColor = '#3085d6')
// example:
alert()->success('SuccessAlert','Lorem ipsum dolor sit amet.')->showConfirmButton('Confirm', '#3085d6');
showCancelButton($btnText = 'Cancel', $btnColor = '#aaa')
// example:
alert()->question('Are you sure?','You won\'t be able to revert this!')->showCancelButton('Cancel', '#aaa');
showCloseButton($closeButtonAriaLabel = 'aria-label')
// example:
toast('Post Updated','success','top-right')->showCloseButton();
hideCloseButton()
// example:
toast('Post Updated','success','top-right')->hideCloseButton();
reverseButtons()
// example:
alert()->question('Are you sure?','You won\'t be able to revert this!')
->showConfirmButton('Yes! Delete it', '#3085d6')
->showCancelButton('Cancel', '#aaa')->reverseButtons();
footer($HTMLcode)
// example:
alert()->error('Oops...', 'Something went wrong!')->footer('<a href="#">Why do I have this issue?</a>');
toToast($position = 'top-right')
// example:
alert()->success('Post Created', 'Successfully')->toToast();
toHtml()
// example:
alert()->success('Post Created', '<strong>Successfully</strong>')->toHtml();
addImage($imageUrl)
This will remove alert type and add close button
// example:
alert('Title','Lorem Lorem Lorem', 'success')->addImage('https://unsplash.it/400/200');
width('32rem')
Modal window width, including paddings (box-sizing: border-box). Can be in px or %. The default width is 32rem.
// example:
alert('Title','Lorem Lorem Lorem', 'success')->width('720px');
padding('1.25rem')
Modal window padding. Can be in px or %. The default padding is 1.25rem.
// example:
alert('Title','Lorem Lorem Lorem', 'success')->padding('50px');
background('#fff')
Modal window background (CSS background property). The default background is '#fff'.
// example:
alert('Title','Lorem Lorem Lorem', 'success')->background('#fff');
animation($showAnimation, $hideAnimation)
Custom animation with Animate.css
// example:
alert()->info('InfoAlert','Lorem ipsum dolor sit amet.')
->animation('tada faster','fadeInUp faster');
Note: Animate.css CDN link is imported in package config file,
buttonsStyling($buttonsStyling)
Apply default styling to buttons. If you want to use your own classes (e.g. Bootstrap classes) set this parameter to false.
// example:
alert()->success('Post Created', 'Successfully')->buttonsStyling(false);
iconHtml($iconHtml)
Use any HTML inside icons (e.g. Font Awesome)
// example:
alert()->success('Post Created', 'Successfully')->iconHtml('<i class="far fa-thumbs-up"></i>);
focusConfirm(true)
Set to false if you want to focus the first element in tab order instead of "Confirm"-button by default.
// example:
alert()->question('Are you sure?','You won\'t be able to revert this!')->showCancelButton()->showConfirmButton()->focusConfirm(true);
focusCancel(false)
Set to true if you want to focus the "Cancel"-button by default.
// example:
alert()->question('Are you sure?','You won\'t be able to revert this!')->showCancelButton()->showConfirmButton()->focusCancel(true);
timerProgressBar()
The timer will have a progress bar at the bottom of a popup. Mostly, this feature is useful with toasts.
// example:
toast('Signed in successfully','success')->timerProgressBar();
How can I help you explore Laravel packages today?