@@ -60,6 +60,8 @@ export interface MatButtonToggleDefaultOptions {
60
60
hideSingleSelectionIndicator ?: boolean ;
61
61
/** Whether icon indicators should be hidden for multiple-selection button toggle groups. */
62
62
hideMultipleSelectionIndicator ?: boolean ;
63
+ /** Whether disabled toggle buttons should be interactive. */
64
+ disabledInteractive ?: boolean ;
63
65
}
64
66
65
67
/**
@@ -78,6 +80,7 @@ export function MAT_BUTTON_TOGGLE_GROUP_DEFAULT_OPTIONS_FACTORY(): MatButtonTogg
78
80
return {
79
81
hideSingleSelectionIndicator : false ,
80
82
hideMultipleSelectionIndicator : false ,
83
+ disabledInteractive : false ,
81
84
} ;
82
85
}
83
86
@@ -136,6 +139,7 @@ export class MatButtonToggleChange {
136
139
export class MatButtonToggleGroup implements ControlValueAccessor , OnInit , AfterContentInit {
137
140
private _multiple = false ;
138
141
private _disabled = false ;
142
+ private _disabledInteractive = false ;
139
143
private _selectionModel : SelectionModel < MatButtonToggle > ;
140
144
141
145
/**
@@ -229,6 +233,16 @@ export class MatButtonToggleGroup implements ControlValueAccessor, OnInit, After
229
233
this . _markButtonsForCheck ( ) ;
230
234
}
231
235
236
+ /** Whether buttons in the group should be interactive while they're disabled. */
237
+ @Input ( { transform : booleanAttribute } )
238
+ get disabledInteractive ( ) : boolean {
239
+ return this . _disabledInteractive ;
240
+ }
241
+ set disabledInteractive ( value : boolean ) {
242
+ this . _disabledInteractive = value ;
243
+ this . _markButtonsForCheck ( ) ;
244
+ }
245
+
232
246
/** The layout direction of the toggle button group. */
233
247
get dir ( ) : Direction {
234
248
return this . _dir && this . _dir . value === 'rtl' ? 'rtl' : 'ltr' ;
@@ -529,6 +543,7 @@ export class MatButtonToggleGroup implements ControlValueAccessor, OnInit, After
529
543
'[class.mat-button-toggle-standalone]' : '!buttonToggleGroup' ,
530
544
'[class.mat-button-toggle-checked]' : 'checked' ,
531
545
'[class.mat-button-toggle-disabled]' : 'disabled' ,
546
+ '[class.mat-button-toggle-disabled-interactive]' : 'disabledInteractive' ,
532
547
'[class.mat-button-toggle-appearance-standard]' : 'appearance === "standard"' ,
533
548
'class' : 'mat-button-toggle' ,
534
549
'[attr.aria-label]' : 'null' ,
@@ -626,6 +641,19 @@ export class MatButtonToggle implements OnInit, AfterViewInit, OnDestroy {
626
641
}
627
642
private _disabled : boolean = false ;
628
643
644
+ /** Whether the button should remain interactive when it is disabled. */
645
+ @Input ( { transform : booleanAttribute } )
646
+ get disabledInteractive ( ) : boolean {
647
+ return (
648
+ this . _disabledInteractive ||
649
+ ( this . buttonToggleGroup !== null && this . buttonToggleGroup . disabledInteractive )
650
+ ) ;
651
+ }
652
+ set disabledInteractive ( value : boolean ) {
653
+ this . _disabledInteractive = value ;
654
+ }
655
+ private _disabledInteractive : boolean ;
656
+
629
657
/** Event emitted when the group value changes. */
630
658
@Output ( ) readonly change : EventEmitter < MatButtonToggleChange > =
631
659
new EventEmitter < MatButtonToggleChange > ( ) ;
@@ -645,6 +673,7 @@ export class MatButtonToggle implements OnInit, AfterViewInit, OnDestroy {
645
673
this . buttonToggleGroup = toggleGroup ;
646
674
this . appearance =
647
675
defaultOptions && defaultOptions . appearance ? defaultOptions . appearance : 'standard' ;
676
+ this . disabledInteractive = defaultOptions ?. disabledInteractive ?? false ;
648
677
}
649
678
650
679
ngOnInit ( ) {
@@ -687,6 +716,10 @@ export class MatButtonToggle implements OnInit, AfterViewInit, OnDestroy {
687
716
688
717
/** Checks the button toggle due to an interaction with the underlying native button. */
689
718
_onButtonClick ( ) {
719
+ if ( this . disabled ) {
720
+ return ;
721
+ }
722
+
690
723
const newChecked = this . isSingleSelector ( ) ? true : ! this . _checked ;
691
724
692
725
if ( newChecked !== this . _checked ) {
0 commit comments