Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

261
Visualizações
Material 2 md-tab-nav-bar wraps on mobile

I want to use tabs for navigation. I followed the documentation verbatim:

<nav md-tab-nav-bar>
  <a md-tab-link
     *ngFor="let link of navLinks"
     [routerLink]="link"
     routerLinkActive #rla="routerLinkActive"
     [active]="rla.isActive">
    {{tabLink.label}}
  </a>
</nav>

<router-outlet></router-outlet>

This looks and works great on desktop:

Looks great on desktop

but looks hideous on mobile:

enter image description here


If I use the md-tab-group (non-nav) tabs, they look great on mobile:

<md-tab-group>
  <md-tab label="Navigation tab 1"></md-tab>
  <md-tab label="Navigation tab 2"></md-tab>
  <md-tab label="Navigation tab 3"></md-tab>
  <md-tab label="Navigation tab 4"></md-tab>
  <md-tab label="Navigation tab 5"></md-tab>
</md-tab-group>

enter image description here

Am I doing something wrong, or is this this a bug in Material 2? Is there a way to make md-tab-nav-bar responsive, or to make md-tab-group work as a nav bar?

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

Yep, <nav mat-tab-nav-bar> doesn't work as the <mat-tab-group>. A possible quick solution I used is to just make the container scroll:

.mat-tab-nav-bar {
  white-space: nowrap;
  overflow: auto;
}

Which looks acceptable and is clean enough, but shows the native scrollbar while scrolling.

over 4 years ago · Santiago Trujillo Relatório

0

I just found this issue that outlines a disconnect between md-tabs and md-tab-nav-bar:

The current "md-tab-group" implementation is already looking great (Dynamic height, scrolling, pagination when tabs exceed container width etc..) But with the "md-tab-nav-bar" component none of these features are available.

It's been assigned and has an "important" tag, so I guess this is an acknowledged by the Material team.

Be sure to head over there and give it a 👍 to help get it prioritized.

over 4 years ago · Santiago Trujillo Relatório

0

There is a potential workaround found at the bottom of the issue that adamport mentioned.

Paraphrased from the workaround (original credits to daiky00):

<nav mat-tab-nav-bar>
    <mat-tab-group>
        <mat-tab *ngFor="let yourVariable of yourLinks">
             <ng-template mat-tab-label>
                <a  mat-tab-link 
                      [routerLink]="yourVariable.path"
                      [routerLinkActiveOptions]="{exact: true}"
                      routerLinkActive #rla="routerLinkActive">
                {{yourVariable.data['label']}} <!-- or however your links are set up-->
                </a>
            </ng-template>
       </mat-tab>
    </mat-tab-group>
</nav>
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda