ngx-materialize icon indicating copy to clipboard operation
ngx-materialize copied to clipboard

Changing the flat button colors

Open Nxt3 opened this issue 6 years ago • 4 comments

How are you supposed to change the color of flat buttons? Doing something like class="blue" just colors the button blue all the time--not when hovered over.

In MaterializeCSS, you're supposed to do class="waves-effect waves-blue btn-flat"--but that doesn't work here.

What am I missing?

Nxt3 avatar Mar 24 '18 07:03 Nxt3

Can you add an example in Stackblitz please? I will be easier to help you.

scote avatar Mar 27 '18 17:03 scote

Sure. Here is an example:

https://stackblitz.com/edit/ngx-materialize-z9vteo

Nxt3 avatar Mar 27 '18 17:03 Nxt3

I actually have the same issue; all flat buttons become green when the mouse is hovered over them and this color cannot be changed (in my case, I would prefer it to be either light gray or transparent).

It's curious 'cause in the documentation website (in the modal, card and buttons sections at least), none of the flat buttons have any color on hover. Trying to override the CSS rules with background-color: whatever !important doesn't help, since it applies the style to all buttons (flat, float and normal buttons alike); fixing the style for flat buttons, but breaking it for the rest.

I think this may be because the mz-button directive adds a CSS class to the element called btn even when the button is flat (in which case it also adds the btn-flat style). The flat button that you have in the documentation website (in the buttons page) only has the btn-flat class, not btn btn-flat as it happens in my code.

caom92 avatar Apr 06 '18 23:04 caom92

So far, the only workaround I can think of is to apply a CSS class to each flat button that overrides the on-hover color. Something like:

.btn.btn-flat.colorless-on-hover:hover {
    background-color:transparent !important;
}

But I think this also overrides the waves effect on click, though I'm not 100% sure.

caom92 avatar Apr 06 '18 23:04 caom92