components icon indicating copy to clipboard operation
components copied to clipboard

feat(button): add support for filled tonal button same as in M3 spec

Open eneajaho opened this issue 1 year ago • 3 comments

Feature Description

https://m3.material.io/components/buttons/guidelines#07a1577b-aaf5-4824-a698-03526421058b

image

Use Case

No response

eneajaho avatar Apr 02 '24 12:04 eneajaho

+1

bradleybeighton avatar May 30 '24 15:05 bradleybeighton

upvoted missing core feature should be implemented.

vulture9 avatar Sep 09 '24 15:09 vulture9

Yes, I also need this.

MariusMoeOlsen avatar Sep 20 '24 12:09 MariusMoeOlsen

+1. This feature should be implemented. In the meantime, we can use the following:

button.mat-tonal-button {
  background-color: var(--sys-secondary-container);
  color: var(--mat-app-on-secondary-container);
}

<button class="mat-tonal-button" mat-button>
</button>

nasser-alkhateeb avatar Nov 18 '24 05:11 nasser-alkhateeb

+1. This feature should be implemented. In the meantime, we can use the following:

button.mat-tonal-button {
  background-color: var(--sys-secondary-container);
  color: var(--mat-app-on-secondary-container);
}

<button class="mat-tonal-button" mat-button>
</button>

In v19, I had to use these slightly differently named CSS vars: --mat-sys-secondary-container --mat-sys-on-secondary-container

JWess avatar Feb 21 '25 23:02 JWess

It's nearly impossible to follow the M3 spec without having access to a tonal button. This seems like a major issue.

JWess avatar Mar 06 '25 16:03 JWess

This is the best workaround I found for now. It piggybacks on the extended fab button, so you're still inside the theme and get appropriate styling for hover/focus/press and probably other things I've not thought of.

<button class="tonal"
  mat-fab extended
>
  Button Text
</button>
.tonal.mat-mdc-extended-fab {
  @include mat.fab-overrides((
    extended-container-height: 40px,
    extended-container-shape: var(--mat-sys-corner-full),
    extended-container-elevation-shadow: var(--mat-sys-level0),
    extended-focus-container-elevation-shadow: var(--mat-sys-level0),
    extended-hover-container-elevation-shadow: var(--mat-sys-level0),
    extended-pressed-container-elevation-shadow: var(--mat-sys-level0),
  ));
}

JWess avatar Mar 06 '25 22:03 JWess