@@ -32,15 +32,13 @@ import {
3232} from '@angular/core' ;
3333import { ControlValueAccessor , NG_VALUE_ACCESSOR } from '@angular/forms' ;
3434import {
35- CanColor ,
36- CanColorCtor ,
3735 CanDisableRipple ,
3836 CanDisableRippleCtor ,
3937 HasTabIndex ,
4038 HasTabIndexCtor ,
41- mixinColor ,
4239 mixinDisableRipple ,
4340 mixinTabIndex ,
41+ ThemePalette ,
4442} from '@angular/material/core' ;
4543import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations' ;
4644
@@ -122,6 +120,9 @@ export class MatRadioGroup implements AfterContentInit, ControlValueAccessor {
122120 @ContentChildren ( forwardRef ( ( ) => MatRadioButton ) , { descendants : true } )
123121 _radios : QueryList < MatRadioButton > ;
124122
123+ /** Theme color for all of the radio buttons in the group. */
124+ @Input ( ) color : ThemePalette ;
125+
125126 /** Name of the radio button group. All radio buttons inside this group will use this name. */
126127 @Input ( )
127128 get name ( ) : string { return this . _name ; }
@@ -302,9 +303,9 @@ class MatRadioButtonBase {
302303}
303304// As per Material design specifications the selection control radio should use the accent color
304305// palette by default. https://material.io/guidelines/components/selection-controls.html
305- const _MatRadioButtonMixinBase : CanColorCtor & CanDisableRippleCtor & HasTabIndexCtor &
306- typeof MatRadioButtonBase =
307- mixinColor ( mixinDisableRipple ( mixinTabIndex ( MatRadioButtonBase ) ) , 'accent' ) ;
306+ const _MatRadioButtonMixinBase :
307+ CanDisableRippleCtor & HasTabIndexCtor & typeof MatRadioButtonBase =
308+ mixinDisableRipple ( mixinTabIndex ( MatRadioButtonBase ) ) ;
308309
309310/**
310311 * A Material design radio-button. Typically placed inside of `<mat-radio-group>` elements.
@@ -314,14 +315,17 @@ const _MatRadioButtonMixinBase: CanColorCtor & CanDisableRippleCtor & HasTabInde
314315 selector : 'mat-radio-button' ,
315316 templateUrl : 'radio.html' ,
316317 styleUrls : [ 'radio.css' ] ,
317- inputs : [ 'color' , ' disableRipple', 'tabIndex' ] ,
318+ inputs : [ 'disableRipple' , 'tabIndex' ] ,
318319 encapsulation : ViewEncapsulation . None ,
319320 exportAs : 'matRadioButton' ,
320321 host : {
321322 'class' : 'mat-radio-button' ,
322323 '[class.mat-radio-checked]' : 'checked' ,
323324 '[class.mat-radio-disabled]' : 'disabled' ,
324325 '[class._mat-animation-noopable]' : '_animationMode === "NoopAnimations"' ,
326+ '[class.mat-primary]' : 'color === "primary"' ,
327+ '[class.mat-accent]' : 'color === "accent"' ,
328+ '[class.mat-warn]' : 'color === "warn"' ,
325329 // Needs to be -1 so the `focus` event still fires.
326330 '[attr.tabindex]' : '-1' ,
327331 '[attr.id]' : 'id' ,
@@ -333,7 +337,7 @@ const _MatRadioButtonMixinBase: CanColorCtor & CanDisableRippleCtor & HasTabInde
333337 changeDetection : ChangeDetectionStrategy . OnPush ,
334338} )
335339export class MatRadioButton extends _MatRadioButtonMixinBase
336- implements OnInit , AfterViewInit , OnDestroy , CanColor , CanDisableRipple , HasTabIndex {
340+ implements OnInit , AfterViewInit , OnDestroy , CanDisableRipple , HasTabIndex {
337341
338342 private _uniqueId : string = `mat-radio-${ ++ nextUniqueId } ` ;
339343
@@ -426,6 +430,14 @@ export class MatRadioButton extends _MatRadioButtonMixinBase
426430 this . _required = coerceBooleanProperty ( value ) ;
427431 }
428432
433+ /** Theme color of the radio button. */
434+ @Input ( )
435+ get color ( ) : ThemePalette {
436+ return this . _color || ( this . radioGroup && this . radioGroup . color ) || 'accent' ;
437+ }
438+ set color ( newValue : ThemePalette ) { this . _color = newValue ; }
439+ private _color : ThemePalette ;
440+
429441 /**
430442 * Event emitted when the checked state of this radio button changes.
431443 * Change events are only emitted when the value changes due to user interaction with
0 commit comments