Skip to content

mat-button-toggle styling issues #14721

Closed

Description

@fad250

Bug 1:

Issue

Applying custom style for checked button toggle gives an odd hover effect.

eg.

.mat-button-toggle-checked{
  background-color: #2979FF;
  color: white;
} 

button-toggle-bug

What are the steps to reproduce?

https://stackblitz.com/edit/angular-ivjb9g

Bug 2:

Issue

In legacy style, button elevation cannot be modified.

What are the steps to reproduce?

https://stackblitz.com/edit/angular-ivjb9g-tdqden

Activity

  1. self-assigned this
    on Jan 4, 2019
  2. added
    P4
    on Jan 4, 2019
  3. added a commit that references this issue on Jan 4, 2019
    e6ba9d3
  4. wottpal commented on Mar 24, 2019

    @wottpal

    Does anybody know a temporary fix? :)

  5. added a commit that references this issue on Jul 27, 2019
    f5e5465
  6. added a commit that references this issue on Feb 10, 2020
    c39a782
  7. added a commit that references this issue on Jun 2, 2020
    01f4386
  8. skobak commented on Jul 2, 2020

    @skobak

    Does anybody know a temporary fix? :)

    A bit ugly hack, but works

    ::ng-deep .mat-button-toggle-appearance-standard:not(.mat-button-toggle-disabled):hover .mat-button-toggle-focus-overlay {
        opacity: 0 !important;
    }
    
  9. blogcraft commented on Jan 4, 2021

    @blogcraft

    I find mat-button-toggle the worst component of Angular Material.

  10. tawani commented on Apr 3, 2021

    @tawani

    I find mat-button-toggle the worst component of Angular Material.

    It is as if they literally wanted to make it horrible.

  11. added 2 commits that reference this issue on May 7, 2021
    0a23dff
    cda2629
  12. zzeneg commented on Sep 21, 2021

    @zzeneg

    For bug 1:
    The problem is in color: white, you have to set it on .mat-button-toggle-checked button to avoid it. Unfortunately it works only with ::ng-deep. https://stackblitz.com/edit/angular-ivjb9g-sse7ch
    On the other hand such overrides should be a part of your custom material theme, so just put it in your theme.scss:

    .mat-button-toggle {
        button {
            color: mat-color($color-primary);
        }
    }
    .mat-button-toggle-checked {
        background-color: mat-color($color-primary);
    
        button {
            color: #fff;
        }
    }
  13. added 2 commits that reference this issue on Feb 20, 2022
    9a12eab
    b703cb3
  14. angular-automatic-lock-bot commented on Mar 23, 2022

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  15. locked and limited conversation to collaborators on Mar 23, 2022
  16. added a commit that references this issue on Apr 3, 2022
    fdc147b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P4area: material/button-toggle

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions