From cc679e03501bf395720ea8fac1dff8023185a600 Mon Sep 17 00:00:00 2001 From: Amy Sorto <8575252+amysorto@users.noreply.github.com> Date: Wed, 26 Jun 2024 15:03:17 +0000 Subject: [PATCH] docs(material/radio): Update description for color input description on API page --- src/material/radio/radio.md | 14 ++------------ src/material/radio/radio.ts | 19 ++++++++++++++++--- tools/public_api_guard/material/radio.md | 1 - 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/material/radio/radio.md b/src/material/radio/radio.md index c63eb2ee3728..aacf130311ed 100644 --- a/src/material/radio/radio.md +++ b/src/material/radio/radio.md @@ -28,16 +28,6 @@ Individual radio-buttons inside of a radio-group will inherit the `name` of the `` is compatible with `@angular/forms` and supports both `FormsModule` and `ReactiveFormsModule`. -### Default Color Configuration -The default color for radio buttons can be configured globally using the `MAT_RADIO_DEFAULT_OPTIONS` provider - -``` -providers: [{ - provide: MAT_RADIO_DEFAULT_OPTIONS, - useValue: { color: 'accent' }, -}] -``` - ### Accessibility `MatRadioButton` uses an internal `` to provide an accessible experience. @@ -56,7 +46,7 @@ should not use the `attr.` prefix when binding these properties, as demonstrated ``` Prefer placing all radio buttons inside of a `` rather than creating standalone -radio buttons because groups are easier to use exclusively with a keyboard. +radio buttons because groups are easier to use exclusively with a keyboard. You should provide an accessible label for all `` elements via `aria-label` or -`aria-labelledby`. +`aria-labelledby`. diff --git a/src/material/radio/radio.ts b/src/material/radio/radio.ts index 7108df397158..7a178900b730 100644 --- a/src/material/radio/radio.ts +++ b/src/material/radio/radio.ts @@ -74,6 +74,13 @@ export const MAT_RADIO_GROUP_CONTROL_VALUE_ACCESSOR: any = { export const MAT_RADIO_GROUP = new InjectionToken('MatRadioGroup'); export interface MatRadioDefaultOptions { + /** + * Theme color of the radio button. This API is supported in M2 themes only, it + * has no effect in M3 themes. + * + * For information on applying color variants in M3, see + * https://material.angular.io/guide/theming#using-component-color-variants. + */ color: ThemePalette; } @@ -481,11 +488,17 @@ export class MatRadioButton implements OnInit, AfterViewInit, DoCheck, OnDestroy this._required = value; } - /** Theme color of the radio button. */ + /** + * Theme color of the radio button. This API is supported in M2 themes only, it + * has no effect in M3 themes. + * + * For information on applying color variants in M3, see + * https://material.angular.io/guide/theming#using-component-color-variants. + */ @Input() get color(): ThemePalette { - // As per Material design specifications the selection control radio should use the accent color - // palette by default. https://material.io/guidelines/components/selection-controls.html + // As per M2 design specifications the selection control radio should use the accent color + // palette by default. https://m2.material.io/components/radio-buttons#specs return ( this._color || (this.radioGroup && this.radioGroup.color) || diff --git a/tools/public_api_guard/material/radio.md b/tools/public_api_guard/material/radio.md index aa72a44de588..f7083a61585a 100644 --- a/tools/public_api_guard/material/radio.md +++ b/tools/public_api_guard/material/radio.md @@ -109,7 +109,6 @@ export class MatRadioChange { // @public (undocumented) export interface MatRadioDefaultOptions { - // (undocumented) color: ThemePalette; }