-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Customize Css Class to the Mat-Tab-Content and other Mat-X tags which are generated runtime #9290
Comments
You are likely just encapsulating your styles. Take a look at this guide and see if it helps: https://material.angular.io/guide/customizing-component-styles |
Why is this closed? <mat-tab> classes are not applied anywhere |
@ovoronin if you place the styles in a global stylesheet or remove view encapsulation from your component styles, they'll be applied. |
@willshowell
Generated HTML is like this
As you can see there are no CSS classes 'first' and 'second' anywhere |
I see. What DOM element would you expect to receive the class? You could do this if you just wanted to style the body: <mat-tab-group>
<mat-tab label="First">
<div class="first">First</div>
</mat-tab>
<mat-tab label="Second">
<div class="second">Second</div>
</mat-tab>
</mat-tab-group> |
@willshowell |
@ovoronin I also wanted to style I fixed them with flexbox using Quick and dirty. It works but I'm quite sure it is not the best option 😟 |
How to disable the animation that have been trigged when tab clicked ngtrigger translate-tab css |
I have the same type of issue, where angular generates a wrapping My intuition tells me this is not the way we should be styling these elements. These generated components should never have to be touched if Angular is/was designed well. However if I change the display to block in DevTools as said above, I get the desired design and with flex I don't so, yeah... if it's possible, would like to know how :D |
@willshowell What if placing them in the global styles is not possible? I have two types of tabs in my mat-tab-group and need to apply different styles to them. How would I accomplish this without applying classes to the specific mat-tabs? |
@shootdaj I think you might be limited to a workaround like some manual class manipulation. @andrewseguin what do you think? would it be possible to allow classes be applied to |
@willshowell
Generated HTML is like this
|
@willshowell Any news on this? It would be great to have some flexibility over the control. I tried to style a specific tab, but the class/style is thrown away when the tabs are generated in the browser. |
You can use ng-template:
|
@shootdaj I found by accident once that you can add global styles with Just use
You can do this to avoid having to put things in root styles - perhaps you don't have access to it, or you're writing a debugging control. Also this approach may not work forever, so you'll have to make your own judgement based on that. I wish they would just officially support |
As of today, the best approach I've found is just using inline styling:
|
we can use CSS :nth-child() Selector. Thank you |
A clean solution would be to:
You can now style both
In some cases you don't want to globally define all component styles, which happens when you disable view encapsulation. To prevent this, simply create a component that's dedicated to display (and style) tab groups. |
I have to hack the css of
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug, feature request, or proposal:
Not able to add customize css class or apply css styling to any Mat-X element that are generated during runtime.
What is the expected behavior?
Customize style and add user defined CSS Class to override the behaviour of element (if required)
What is the current behavior?
Not applied
What are the steps to reproduce?
This is my html body
Below is the Generated Html when it runs in the browser(Chrome).
.
REQUEST.
Want to add "MyTabClass" to the "div.mat-tab-body-content". I tried adding css style using !important, but still fails to apply custom styling or custom css class to the tags which are generated at runtime.
Please anybody aware about how to implement this guide me.
I am new to the Material Design with Angular 2
What is the use-case or motivation for changing an existing behavior?
To have a upperhand in the styling, when required. Usually we are using the default behaviour of material controls.
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Latest version of all.
OS- windows 10
Is there anything else we should know?
Yes, this is not specifically related to the Mat-tabs. I was searching the way to apply custom css to any of the mat-X controls sub-elements which are auto-generated during rendering in browser
The text was updated successfully, but these errors were encountered: