1

I'm using progress bar from Angular Material and trying to custom-style it. I can set the borders, radiues, color of the progressed part (buffer?) simply by styling the element itself (e.g. md-progress-bar { border: 1px solid black }) but I cannot add the background color for the bar. If I change the background color of the .mat-progress-bar-buffer via dev tools, it works, but if not via component css (or any other css, for that matter).

So, this doesn't work:

.mat-progress-bar-buffer {
  background-color: $white;
}

What else can I try?

Edit: here's a simple plunker to play with.

7
  • tried !important? Commented Jul 19, 2017 at 19:38
  • Yep, of course :) Commented Jul 19, 2017 at 19:39
  • I am not sure they used background-image with some svg in .mat-progress-bar-background. Commented Jul 19, 2017 at 19:48
  • Try opening the plunker, find that element in dev tools. If you add background-color: white to it, it works. Commented Jul 19, 2017 at 19:49
  • 1
    plunker not working, clean state btw. Commented Jul 19, 2017 at 19:50

2 Answers 2

2

Not sure if this will be any better, however since /deep/ and >>> will be deprecated from browsers support, angular have it's own way to emulate this using ::ng-deep and is the prefer way until better solution is found.

Documentation on angular says it will be deprecated however on github vicb mention that they have no plan to remove ::ng-deep in a near future.

Usage is similar to /deep/:

::ng-deep .mat-progress-bar-buffer {}

Sign up to request clarification or add additional context in comments.

1 Comment

I know /deep/ is going away, but I need this for now. Anyway, TIL about :host ::ng-deep :)
1

Well, it's due to ViewEncapsulation. If I add /deep/ .mat-progress-bar-buffer, the style is applied.

I'd still like to find a better solution (with /deep/ being all but gone).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.