Working with Angular 9 and ngx-toastr has presented me with an interesting challenge.
I am tasked with creating custom toast styles that differ significantly from the default ones provided by toastr. Each toast in the set will have unique border colors, fontawesome icons, and messages.
Check out one of the toast mockups here: enter image description here
ngx-toastr comes with its own toastr.css style sheet, which I have added to angular.json. Without this addition, the toasts do not render properly. In order to achieve my desired customizations, I created a separate toast-messages.scss file containing all the necessary CSS properties based on my mockup design. This file is also included in angular.json.
"styles": [
"node_modules/@fortawesome/fontawesome-free/css/fontawesome.css",
"node_modules/@fortawesome/fontawesome-free/css/solid.css",
"src/styles.scss",
"node_modules/ngx-toastr/toastr.css",
"src/app/styles/toast-messages.scss"
],
Unfortunately, I've encountered an issue where every line in my toast-messages.scss file requires an !important declaration to override styles defined in toastr.css, making the process cumbersome.
My question is: What other options do I have for styling these toasts without relying heavily on !important tags in my CSS? Could I be referencing the CSS/SCSS files incorrectly? Is there a recommended approach for creating custom toast designs, considering I am relatively new to Angular (just 2 months in)?
toast-messages.scss (Note: formatting needs improvement due to trial and error)
.toast-container .ngx-toastr {
/* Custom styles */
}
/* Other classes and styles for the toast messages go here */