diff --git a/src/components-examples/material/badge/badge-overview/badge-overview-example.html b/src/components-examples/material/badge/badge-overview/badge-overview-example.html index aeea433e5618..eab17a82714a 100644 --- a/src/components-examples/material/badge/badge-overview/badge-overview-example.html +++ b/src/components-examples/material/badge/badge-overview/badge-overview-example.html @@ -3,14 +3,14 @@ +
Text with small badge
Text with large badge
Button with a badge on the left - @@ -28,7 +28,7 @@
Icon with a badge - home + home diff --git a/src/material/badge/badge.md b/src/material/badge/badge.md index 9a636d75d053..c3263b2e94df 100644 --- a/src/material/badge/badge.md +++ b/src/material/badge/badge.md @@ -1,4 +1,4 @@ -Badges are small status descriptors for UI elements. A badge consists of a small circle, +Badges are small status descriptors for UI elements. A badge consists of a small circle, typically containing a number or other short set of characters, that appears in proximity to another object. @@ -13,7 +13,7 @@ By default, the badge will be placed `above after`. The direction can be changed the attribute `matBadgePosition` follow by `above|below` and `before|after`. The overlap of the badge in relation to its inner contents can also be defined @@ -21,32 +21,27 @@ using the `matBadgeOverlap` tag. Typically, you want the badge to overlap an ico a text phrase. By default it will overlap. ### Badge sizing The badge has 3 sizes: `small`, `medium` and `large`. By default, the badge is set to `medium`. + +Badges that are `small` do not show the label text. This can be useful in contexts such as showing there are unread notifications but not needing to show the exact amount. + You can change the size by adding `matBadgeSize` to the host element. ### Badge visibility The badge visibility can be toggled programmatically by defining `matBadgeHidden`. -### Theming -Badges can be colored in terms of the current theme using the `matBadgeColor` property to set the -background color to `primary`, `accent`, or `warn`. - - - ### Accessibility You must provide a meaningful description via `matBadgeDescription`. When attached to an interactive element, `MatBadge` applies this description to its host via `aria-describedby`. When attached to diff --git a/src/material/badge/badge.ts b/src/material/badge/badge.ts index 14f8a9daf616..4b8676981409 100644 --- a/src/material/badge/badge.ts +++ b/src/material/badge/badge.ts @@ -83,7 +83,10 @@ export class _MatBadgeStyleLoader {} standalone: true, }) export class MatBadge implements OnInit, OnDestroy { - /** The color of the badge. Can be `primary`, `accent`, or `warn`. */ + /** + * The color of the badge. Can be `primary`, `accent`, or `warn`. + * Not recommended in M3, for more information see https://material.angular.io/guide/material-2-theming#optional-add-backwards-compatibility-styles-for-color-variants. + */ @Input('matBadgeColor') get color(): ThemePalette { return this._color;