@@ -19,7 +19,7 @@ import {
1919 input ,
2020 signal ,
2121} from '@angular/core' ;
22- import { TabPattern , TabPanelPattern , DeferredContentAware } from '../private' ;
22+ import { DeferredContentAware , LabelControl , TabPattern , TabPanelPattern } from '../private' ;
2323import { TABS } from './tab-tokens' ;
2424
2525/**
@@ -49,7 +49,8 @@ import {TABS} from './tab-tokens';
4949 '[attr.id]' : '_pattern.id()' ,
5050 '[attr.tabindex]' : '_pattern.tabIndex()' ,
5151 '[attr.inert]' : '!visible() ? true : null' ,
52- '[attr.aria-labelledby]' : '_pattern.labelledBy()' ,
52+ '[attr.aria-label]' : '_labelControl.label()' ,
53+ '[attr.aria-labelledby]' : '_labelControl.labelledBy()' ,
5354 } ,
5455 hostDirectives : [
5556 {
@@ -71,9 +72,18 @@ export class TabPanel implements OnInit, OnDestroy {
7172 /** The parent Tabs. */
7273 private readonly _tabs = inject ( TABS ) ;
7374
75+ /** Controls label for this tabpanel. */
76+ readonly _labelControl : LabelControl ;
77+
7478 /** A global unique identifier for the tab. */
7579 readonly id = input ( inject ( _IdGenerator ) . getId ( 'ng-tabpanel-' , true ) ) ;
7680
81+ /** The (optional) label for the accordion panel. */
82+ readonly label = input < string | undefined > ( undefined ) ;
83+
84+ /** The (optional) labelledBy ids for the accordion panel. */
85+ readonly labelledBy = input < string [ ] > ( [ ] ) ;
86+
7787 /** The Tab UIPattern associated with the tabpanel */
7888 readonly _tabPattern : WritableSignal < TabPattern | undefined > = signal ( undefined ) ;
7989
@@ -90,6 +100,12 @@ export class TabPanel implements OnInit, OnDestroy {
90100 } ) ;
91101
92102 constructor ( ) {
103+ this . _labelControl = new LabelControl ( {
104+ defaultLabelledBy : computed ( ( ) => this . _pattern ! . labelledBy ( ) ) ,
105+ label : this . label ,
106+ labelledBy : this . labelledBy ,
107+ } ) ;
108+
93109 afterRenderEffect ( {
94110 write : ( ) => {
95111 this . _deferredContentAware . contentVisible . set ( this . visible ( ) ) ;
0 commit comments