components icon indicating copy to clipboard operation
components copied to clipboard

[Tabs] Ability to hide tabs header

Open faisalmuhammad opened this issue 8 years ago • 16 comments

Bug, feature request, or proposal:

Feature request

What is the expected behavior?

The mat-tab-group should expose a property using which the header can be hidden. Setting the property to true should hide the header of the mat-tab-group.

What is the current behavior?

At the moment. in order to hide the header, I have to override the default styles of the class ".mat-tab-header" and set the display property to none along with setting component's encapsulation to encapsulation: ViewEncapsulation.None. Given below is an example how I am currently hiding the tab header:

CSS Styles

.header-less-tabs.mat-tab-group .mat-tab-header {
  display: none;
}

TypeScript

import { Component, ViewEncapsulation } from '@angular/core';

@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: [ './app.component.css' ],
  encapsulation: ViewEncapsulation.None
})
export class AppComponent  { 
}

Html Template

<mat-tab-group class="header-less-tabs">
  <mat-tab label="Tab 1">Content 1</mat-tab>
  <mat-tab label="Tab 2">Content 2</mat-tab>
</mat-tab-group>

What are the steps to reproduce?

Here is a link to StackBlitz Demo of what I am looking to achieve.

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

I have an app where I am loading different contents/sections inside the mat-tab-group, and I am using a sidebar with the buttons to navigate. Also, the navigation happens from inside any tab. I do not have any routes in the app, so using "mat-tab-nav-bar" is not an option.

faisalmuhammad avatar Jan 15 '18 13:01 faisalmuhammad

I would very much like this feature too.

I have a list of products categories and only some have sub categories. I am displaying the products in a sub category in a tab control, but when there is only a single sub category I don't want to display the tab control header. Would be much simpler template if I had this property.

simeyla avatar May 18 '18 00:05 simeyla

Is this feature going to be added anytime soon?

weilip1803 avatar Oct 26 '18 06:10 weilip1803

Is this feature going to be added sometime? or has anyone figured out a workaround to hide it?

andystroz avatar Nov 02 '18 13:11 andystroz

@andystroz faisalmuhammad's example on StackBlitz is pretty straightforward. I used it like this:

In styles.css: .header-less-tabs .mat-tab-group .mat-tab-header { display: none; }

In the template: <div [ngClass]="{ 'header-less-tabs': formTabs.length === 1}"> --- <mat-tab-group ...> --- </mat-tab-group> </div>

where formTabs is an array variable in my component.

Sjonnie2nd avatar Nov 14 '18 14:11 Sjonnie2nd

Really wish some of these 'low priority' tasks that should be simple to implement could be prioritized more highly :-/

simeyla avatar Nov 28 '18 04:11 simeyla

Please implement this feature. It will allow using mat-tab-group as missing carousel control (from bootstrap).

stasberkov avatar May 29 '19 11:05 stasberkov

length

Even simpler without the need of the extra wrapper or the component variable:

In styles.css: .header-less-tabs .mat-tab-header { display: none; }

In the template: <mat-tab-group #matTabGroup [class.header-less-tabs]="matTabGroup._tabs.length <= 1">

philip-firstorder avatar Jun 19 '19 13:06 philip-firstorder

Lending my voice to the crowd, lest this issue fall victim to the auto-close.

Tabs are awesome, and like others here, I am looking to separate the tab header from the tab group or hide it completely, so I can use tabs for navigation where routing is not possible.

lucas-entronic avatar Oct 31 '19 21:10 lucas-entronic

Yeah, this feature would be really cool!!

phillipe-barbosa avatar Jun 24 '20 15:06 phillipe-barbosa

I'd like to not only hide the tab group, I'd like to hide a specific matTabLabel.

By hiding a label, you could still navigate to the content via button somewhere else and you'd get all of the nice slide in/slide out effects for free.

Should that be a separate feature request?

rramsey avatar Dec 16 '20 19:12 rramsey

Agree. I'd like a multi-step process without the tab labels but with all the cool animations built-in. I've got a sign-in page with three phases: (1) enter your email (2) wait for email to be sent, like a big progress ring, (3) done, go check your email.

jmagaram avatar Mar 06 '21 00:03 jmagaram

Thanks for bringing this up! I found this after hours of searching...

here's how I did it: add this to the css file and presto!

::ng-deep .mat-tab-group > .mat-tab-header{ display: none; }

Avramo avatar Mar 22 '21 15:03 Avramo

I would like this feature.

RAAvenger avatar Jun 06 '21 12:06 RAAvenger

The tabs component follows the guidance of the tabs accessibility pattern: https://www.w3.org/WAI/ARIA/apg/patterns/tabpanel/

The header plays an important part in this pattern to help all users navigate the content. Displaying the tabpanel elements without a tablist containing a set of tab elements would break this interaction.

Some comments alude to having the tablist elsewhere on the page (e.g. a side nav) which could be a valid workaround. However this sounds closer to the mat-tab-nav-bar usage which does allow separation of links and content. Note that the router is not required to use the nav bar.

Other comments seem to want the content sliding interaction simply for the animation. In those cases I recommend building a custom component that animates content. The tab group should not be favored simply for its visual interaction, since it implies an accessibility pattern that means something for users depending on tools like screen readers.

andrewseguin avatar Jun 29 '22 12:06 andrewseguin

I had to create my own whole tab control because of this. Not because I wanted to hide the bar, not because I wanted the animation but because most of the time my tab control only contains one item. In which case tabs made no sense and wasted space. When developers have to do this I guarantee accessibility ends up far worse off!

Perhaps reconsider for this reason alone? HideNavigationIfOnlyOneTab

simeyla avatar Jun 29 '22 17:06 simeyla

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.