components icon indicating copy to clipboard operation
components copied to clipboard

FR: Allow dynamically changing the ink bar color in MdTabGroup

Open henrikssn opened this issue 10 years ago • 10 comments

Bug, feature request, or proposal:

Feature request

What is the expected behavior?

There should be a way to dynamically (from parent component) change the color of the md-ink-bar in the material tabs.

What is the use-case or motivation for changing an existing behavior?

We need it in our product.

Which versions of Angular, Material, OS, browsers are affected?

Angular material

henrikssn avatar Jul 29 '16 10:07 henrikssn

@henrikssn Can you provide more information about your specific use-case?

robertmesserle avatar Aug 01 '16 23:08 robertmesserle

We have a color in the parent component which we also want to use for the ink bar. The color depends on data which we get dynamically.

henrikssn avatar Aug 22 '16 14:08 henrikssn

.md-tab-header md-ink-bar {
    background-color: #00b1ff;
}

johnnysainz avatar Aug 26 '16 05:08 johnnysainz

Hey Johny, your example uses a constant color, this issue is about having a "dynamic" color coming from the component's inputs.

tomsdev avatar Aug 26 '16 09:08 tomsdev

@johnnysainz why not use sass or less? You can put colors into variables in sass/less for example.

guntram avatar Oct 13 '16 14:10 guntram

You might as well get used to using the following because you'll run into issues like this constantly using material design.

ngAfterViewInit() { let bar = document.querySelector('md-ink-bar'); this._render.setElementStyle(bar, 'backgroundColor', 'red'); }

PostImpatica avatar Nov 03 '16 16:11 PostImpatica

If you do something like this, it would be better to change the classes! You can do this with a wrapping element:

[ngClass]="{'first': myConditionForFirst, 'second': true, 'third': false}"
.first md-ink-bar { background-color: red; }
.second md-ink-bar { background-color: pink; }

Taken from ngDox

guntram avatar Nov 03 '16 16:11 guntram

@guntram I've spent hours trying to get your method working. I would rather use it but I give up.

PostImpatica avatar Nov 03 '16 20:11 PostImpatica

This can be done by using a dynamically changing class name for the tab group based on the selected tab.

Here's a rough working proof of concept that can act as your starter: http://plnkr.co/edit/m4anq3XWMOpEDAkjIJtg?p=preview

andrewseguin avatar Nov 11 '16 21:11 andrewseguin

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.