components icon indicating copy to clipboard operation
components copied to clipboard

How to style md-tab?

Open RedFour opened this issue 10 years ago • 12 comments

How do I style the md-tab?

I've created a few test tabs using the documentation. But I can't figure out how to make the tab's width to be smaller. The default width is too large for mobile screens.

<md-tab-group selectedIndex=0>
  <md-tab style="width:50px">
    <template md-tab-label>Tab1</template>
      <h1>Some more tab content</h1>
      <p>...</p>
    <template md-tab-content>
    </template>
  </md-tab>
  <md-tab>
    <template md-tab-label>Tab2</template>
    <template md-tab-content>
      <h1>Some more tab content</h1>
      <p>...</p>
    </template>
  </md-tab>
</md-tab-group>

RedFour avatar Aug 21 '16 01:08 RedFour

This would fall under #123

jelbourn avatar Aug 22 '16 16:08 jelbourn

@jelbourn, @RedFour seems to specifically be talking about this, which doesn't look slated for theming at the moment. Dynamic changes to the width of the tabs probably aren't in the scope of app wide theming either.

Imo md-tab-labels shouldn't have a min-width. They should expand and contract to the width of the md-tab-group, keeping the tabs responsive after that is the developer's job.

I get that there is a lot more work to be done on md-tabs, for the mean time changing the min-width: 160px; to width: 100%; would make md-tabs a lot more usable and responsive.

hstevensagain avatar Aug 23 '16 04:08 hstevensagain

@hstevensagain thx! the css code you gave worked!

/deep/ .md-tab-label {
  min-width: 1px !important;
}

RedFour avatar Aug 23 '16 22:08 RedFour

@hstevensagain @RedFour I'm having the same problem, but the css code above isn't working... any other workarounds?

sebaswn avatar Mar 14 '17 17:03 sebaswn

@RedFour where did you added this code

ravinderpayal avatar Apr 05 '17 04:04 ravinderpayal

@RedFour @ravinderpayal Actually the class name is mat-tab-label. Hence, the correct style is:

.mat-tab-label {
  min-width: 1px !important;
}

luisfpg avatar Apr 17 '17 14:04 luisfpg

Do you know how we can do the same on only one tab? tried pretty much everything without success.

mist3r3 avatar May 22 '17 15:05 mist3r3

can we open this? I can't get anyone of these examples working..

axhcypod avatar Aug 09 '17 12:08 axhcypod

@mist3r3 you can specify the element number

/deep/ .mat-tab:nth-child(1) {
    min-width: 100px !important;
  }

captain-melanie avatar Dec 16 '17 04:12 captain-melanie

What if you need smaller tabs on only one page not the entire application.

jdewell avatar Apr 18 '18 22:04 jdewell

I got the page I wanted the smaller tabs like this: #groupTabGroup ::ng-deep.mat-tab-label, ::ng-deep.mat-tab-label-active{ min-width: 0; padding: 3px; margin: 3px; } I had to give the mat-tab-group an id and specify that id in the css.

jdewell avatar Apr 19 '18 15:04 jdewell

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.