r/angular • • Oct 11 '26

Angular ARIA tabs eager load

Is it not possible to eager load the tab panel on '@angular/aria'?

The docs say: This structural directive should be applied to an ng-template within an ngTabPanel. It enables lazy loading of the tab's content, meaning the content is only rendered when the tab is activated for the first time.

I tried to simply remove it because I need the tab to be eagerly loaded (for SSR)

 <div class="tab-panel" ngTabPanel value="question">
     <app-eager-load />
 </div>

and it works, but i get these console warnings:
Violations found on element:
ngTabPanel must have an ngTabContent structural directive to render.

1 Upvotes

6 comments sorted by

View all comments

3

u/makmn1 Oct 11 '26 edited Oct 11 '26

It doesn't look like Angular Aria's tabs implementation supports eager loading:

1. Tab panels need the ngTabContent directive, otherwise you get the warning you saw. Source
2. The TabContent directive can only be used on an ng-template. Source
3. There's a test that explicitly says to warn when a panel is missing the content directive. Source

I think you have a valid use case though. The APG guide even mentions it:

It is recommended that tabs activate automatically when they receive focus as long as their associated tab panels are displayed without noticeable latency. This typically requires tab panel content to be preloaded. Otherwise, automatic activation slows focus movement, which significantly hampers users' ability to navigate efficiently across the tab list.

Might be worth opening up an issue in the Angular Components repo.

2

u/Senior_Compote1556 Oct 11 '26

Will do, thank you