Skip to content

bug(snack-bar): action button color not changeable #27328

Closed
@dkimmich-onventis

Description

@dkimmich-onventis

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

14

Description

I have a snack bar with a custom component. In this component I have a custom action button. I want this button to be in the primary color, so I set the color attribute of the button to "primary":

<button mat-button color="primary" matSnackBarAction>
  My custom action
</button>

Before MDC, the color attribute was respected, and the button changed its color accordingly. After MDC migration, the button stays in the accent color regardless of what color is set.

Reproduction

StackBlitz link: https://stackblitz.com/edit/kbv7nf

Steps to reproduce:

  1. Create a custom snack bar component / template
  2. Add an action button to the custom snack bar
  3. Set the color of the action button to "primary"

Expected Behavior

The button is displayed in the primary color

Actual Behavior

The button is displayed in the accent color

Environment

  • Angular: 16
  • CDK/Material: 16
  • Browser(s): all
  • Operating System (e.g. Windows, macOS, Ubuntu): all

Further notes

I investigated the issue a bit, and it seems like using the matSnackBarAction directive overrides the color of the button. Omitting this directive fixes the issue, however the docs state that this directive should be used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/button

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions