angular / angular/components

Option to have no tab selected in mat-tab-group

Open
#18,316 12 comments 18 reactions 0 assignees View on GitHub
area: material/tabs feature G P4
Dominant language
TypeScript
Stars
25k
Forks
6.8k
Avg merge
1d 8h
Merged PRs (30d)
91

Description

#### Feature Description

Allow MatTabGroup to have a state where no tab is selected/active. The current behavior always has a tab selected/active.

Currently, MatTabGroup has a selectedIndex property with type number | null, but setting it to null does not unselect any of the tabs; the first tab is selected/active by default. I think that it would be more intuitive if setting selectedIndex to null unselected all of the tabs.

#### Use Case

Adding this feature would allow for a tab group to be in a collapsed state where no tab is selected and only the header is visible. Clicking one of the tabs in the header would then set the selected tab, the current behavior. This would provide more flexibility in using tabs for a layout.

Contributor guide

Open the contributing guide

Research direction

Start at the MatTabGroup selectedIndex handling and read the existing tab-selection tests. Verify how a null selectedIndex is treated, then define the completed behavior as allowing no tab to be active while preserving header clicks that select a tab.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.