@@ -60,6 +60,8 @@ export interface MatButtonToggleDefaultOptions {
6060 hideSingleSelectionIndicator ?: boolean ;
6161 /** Whether icon indicators should be hidden for multiple-selection button toggle groups. */
6262 hideMultipleSelectionIndicator ?: boolean ;
63+ /** Whether disabled toggle buttons should be interactive. */
64+ disabledInteractive ?: boolean ;
6365}
6466
6567/**
@@ -78,6 +80,7 @@ export function MAT_BUTTON_TOGGLE_GROUP_DEFAULT_OPTIONS_FACTORY(): MatButtonTogg
7880 return {
7981 hideSingleSelectionIndicator : false ,
8082 hideMultipleSelectionIndicator : false ,
83+ disabledInteractive : false ,
8184 } ;
8285}
8386
@@ -136,6 +139,7 @@ export class MatButtonToggleChange {
136139export class MatButtonToggleGroup implements ControlValueAccessor , OnInit , AfterContentInit {
137140 private _multiple = false ;
138141 private _disabled = false ;
142+ private _disabledInteractive = false ;
139143 private _selectionModel : SelectionModel < MatButtonToggle > ;
140144
141145 /**
@@ -229,6 +233,16 @@ export class MatButtonToggleGroup implements ControlValueAccessor, OnInit, After
229233 this . _markButtonsForCheck ( ) ;
230234 }
231235
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+
232246 /** The layout direction of the toggle button group. */
233247 get dir ( ) : Direction {
234248 return this . _dir && this . _dir . value === 'rtl' ? 'rtl' : 'ltr' ;
@@ -529,6 +543,7 @@ export class MatButtonToggleGroup implements ControlValueAccessor, OnInit, After
529543 '[class.mat-button-toggle-standalone]' : '!buttonToggleGroup' ,
530544 '[class.mat-button-toggle-checked]' : 'checked' ,
531545 '[class.mat-button-toggle-disabled]' : 'disabled' ,
546+ '[class.mat-button-toggle-disabled-interactive]' : 'disabledInteractive' ,
532547 '[class.mat-button-toggle-appearance-standard]' : 'appearance === "standard"' ,
533548 'class' : 'mat-button-toggle' ,
534549 '[attr.aria-label]' : 'null' ,
@@ -626,6 +641,19 @@ export class MatButtonToggle implements OnInit, AfterViewInit, OnDestroy {
626641 }
627642 private _disabled : boolean = false ;
628643
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+
629657 /** Event emitted when the group value changes. */
630658 @Output ( ) readonly change : EventEmitter < MatButtonToggleChange > =
631659 new EventEmitter < MatButtonToggleChange > ( ) ;
@@ -645,6 +673,7 @@ export class MatButtonToggle implements OnInit, AfterViewInit, OnDestroy {
645673 this . buttonToggleGroup = toggleGroup ;
646674 this . appearance =
647675 defaultOptions && defaultOptions . appearance ? defaultOptions . appearance : 'standard' ;
676+ this . disabledInteractive = defaultOptions ?. disabledInteractive ?? false ;
648677 }
649678
650679 ngOnInit ( ) {
@@ -687,6 +716,10 @@ export class MatButtonToggle implements OnInit, AfterViewInit, OnDestroy {
687716
688717 /** Checks the button toggle due to an interaction with the underlying native button. */
689718 _onButtonClick ( ) {
719+ if ( this . disabled ) {
720+ return ;
721+ }
722+
690723 const newChecked = this . isSingleSelector ( ) ? true : ! this . _checked ;
691724
692725 if ( newChecked !== this . _checked ) {
0 commit comments