Guide to customizing action button color on MatSnackbar?

Currently, I am encountering an issue with the snackbar in my Angular 9 project. Despite adding CSS styles to both the component.scss file and the global style.scss file, the action button on the snackbar displays the same background and text color. In an attempt to resolve this, I utilized the following code:

this._snackBar.open(`Chart has been copied to ${workspace.name}`, 'Check it out!', 
{ duration: 5000, panelClass: "blue-snackbar"}).onAction().subscribe(() => {})

I have also experimented with this alternative approach:
panelClass: ['my-snack-bar', 'button-bar']}

Furthermore, I incorporated the following styling rules into the styles.scss and component.scss files:

.my-snack-bar {
    background-color: #E8EAF6;
    color: red;
}
.button-bar {
    background-color: pink;
    color: blue;
}

For reference, please see the example image here: https://i.sstatic.net/m6Qph.jpg

Despite these efforts, the issue persists. Any suggestions or assistance regarding this matter would be greatly appreciated.

Answer №1

To style the panelClass property in your global styles file, typically styles.scss, you will need to specify it like this:

.my-snack-bar {
    background: #2196F3;
    button {background:white; color: blue}
}

Check out this live example https://stackblitz.com/edit/angular-stacb4-b1fuu5

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

In order to activate the VScode Tailwind CSS Intellisense plugin, I have discovered that I need to insert a space before

I recently followed the installation guide for using Tailwind with Next.js Here is a snippet from my tailwind.config.js file: /** @type {import('tailwindcss').Config} */ module.exports = { content: [ "./app/**/*.{js,ts,jsx,tsx}", ...

Can the Bootstrap grid be arranged vertically?

I'm finding it difficult to work on a project with Bootstrap's horizontal grid system. What I want to achieve is to have my page divided into 4 sections, with the left side blocks having equal height and the right side blocks having varying heigh ...

Hover effect malfunctioning on the website

I am in the process of building a website using WordPress with the 2017 theme. I recently added a link to my page by inserting the following HTML code: <a href="www." target="_blank"><span style="color: #0000ff;">text</span></a> A ...

What's the reason for the align-self: flex-end CSS property not working as expected on a flex div element?

I am trying to align the "Click me" button to the left of the div that contains it. Here is my code: render = () => { return ( <Wrapper> <Body> <span>Title</span> <Desc ...

What could be causing the 404 Ajax not found error in my script?

I'm facing an issue with my code. When I try to run it, I encounter the following error: 404 (Not Found) while using the get method. Here is my html code snippet. <html> <head> <title>Issue</title> <meta charset= ...

Setting up nginx docker image to host an angular application while also enabling page refresh is a straightforward process. Here

After reviewing numerous instances of individuals suggesting to simply paste location / { try_files $uri $uri/ /hockey/index.html =404; } or location / { try_files $uri $uri/ /index.html =404; } ...or experimenting with different ...

Launching Angular 2 application on Heroku

Previously, I would combine my Angular 1 and Rails applications and deploy them on Heroku, which always went smoothly. However, now that I've transitioned to Angular 2, I'm looking to segregate my Angular and Rails code. I've successfully cr ...

How to create a thumbnail hover effect with CSS3 and javascript, overcoming the z-axis issue

Currently, I am working on creating a set of thumbnails that enlarge when hovered over. The initial setup achieves the zoom effect using CSS3 transform:scale and ease-in-out. However, the issue is that the enlarged images overlap each other due to sharing ...

Shifting the entire page from left to right and back again

I am in search for a template that moves the page from left to right. If anyone can guide me on how to create this effect or provide a JavaScript example, I would greatly appreciate it. ...

Angular: updating a single route triggers multiple 'NavigationEnd' events

I am currently working with Angular 4 and have written the following code in one of my components to detect when a route has changed and reload the page: ngOnInit() { this.router.events.subscribe((value) => { if (value instanceof Navi ...

angular-cli is throwing an error indicating that the current version is outdated

While working on one of my Angular 2 projects, I encountered an error when trying to run and test the app using the <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c7a6a9a0b2aba6b5eaa4abae87f6e9f7e9f7eaa5a2b3a6e9f6f2">[email& ...

The Weglot country selector is not properly aligned with the rest of the content and its hover

Our Woocommerce store is now multilingual thanks to the weglot plugin. In the desktop view, we have integrated the country selector next to the shopping cart. For mobile view, we placed the HTML Widget in the header with some surrounding code: <div clas ...

Implement a vertical scrolling animation in datatables

I am trying to utilize datatables to display all data. My goal is to have the data automatically scroll row by row every 3 seconds. This is my code, and you can also check it out on jsfiddle The intention is to showcase this data on a large screen. < ...

What is the process for verifying that a p-datatable has been successfully generated on the page?

Imagine having a parent component and a child component. <button (click)="downloadReport()">Download Report</button> <app-child-component [reportMode]="reportMode" (onReportModeReady)="onReportModeReady"> </app-child-component> I ...

How to extract JSON data without HTML tags in Android Studio

i'm done with my android studio project. i have successfully stored data from wp-json. however, there seems to be an issue where I am getting the following: <p>আল্লামা আহমদ শফীর ইন্তেকালের পর ...

Troubleshooting the Width Problem in Bootstrap 5 Dropdowns

I am currently working on a new project and encountering an issue with the width of a Bootstrap 5 dropdown. The problem lies in the discrepancy between the button width and the menu width. Although it may seem simple, I am having trouble resolving it as I ...

Navigate to a different component within Angular

Is there a way in Angular to scroll to a component using a button placed in another component? Below is the code snippet for the first component: <div id='banner' class="col-5 offset-1 d-flex justify-content-center align-items-cen ...

Duplicate NgRx Effects found during loading process

My feature module is quite simple; it offers services and imports its own stats fragment as a feature: @NgModule({ imports: [ CommonModule, StoreModule.forFeature('alarms', alarmsReducer, { initialState: alarmsInitialState }), Effe ...

Check if the element is located on the active tab using jQuery

I have implemented a tab system to organize a lengthy form with multiple input fields. The form consists of 4 tabs, and beneath them, there is a preview section displaying the user's selections. In this preview area, I added icons that enable users ...

The bar chart in chartjs is not displaying properly due to incorrect grouping

I attempted to generate a multi bar chart using Chart.js, but encountered an issue where the jobType and jobCount were not displayed correctly based on each companyName. Below is the table: Here is the PHP file (CompanySelection.php): <?php header(& ...