material-web icon indicating copy to clipboard operation
material-web copied to clipboard

[mwc-button] outlined button --mdc-theme-primary will also set button text color

Open chxx-v opened this issue 3 years ago • 3 comments

[mwc-button] outlined button --mdc-theme-primary will also set button text color, using --mdc-theme-on-primary won't set the text color. eg:

<body>
  <style>

    mwc-button[outlined] {
      --mdc-theme-primary: yellow;
      --mdc-theme-on-primary: black;
      --mdc-button-outline-color: red;
    }
    
  </style>
  <mwc-button outlined label="Button" unelevated></mwc-button>
  <mwc-button outlined label="Button"></mwc-button>
</body>
Screen Shot 2022-02-14 at 3 26 58 PM The button text is controlled by --mdc-theme-primary; and at unelevated state, the whole button will be yellow, with no text shown. I want an outlined unelevated button with different background color and text color.

chxx-v avatar Feb 14 '22 19:02 chxx-v

Screen Shot 2022-02-14 at 3 47 54 PM this will be my goal

chxx-v avatar Feb 14 '22 20:02 chxx-v

Screen Shot 2022-02-14 at 3 47 54 PM this will be my goal

@chxx-v you can override the CSS vars in your button element through the style attribute or via CSS class:

<mwc-button style="--mdc-theme-primary: black;"></mwc-button>

maicol07 avatar Feb 19 '22 20:02 maicol07

@maicol07 but when the option is selected, it will fill the whole background with black color, no text can be read...

chxx-v avatar Feb 22 '22 15:02 chxx-v

Fixed in M3

asyncliz avatar Apr 25 '23 04:04 asyncliz