Skip to content

Commit d15df24

Browse files
authored
docs(material/badge): minor doc fixes (#29233)
1 parent 69d39a8 commit d15df24

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

src/components-examples/material/badge/badge-overview/badge-overview-example.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
<!-- #enddocregion mat-badge-overlap -->
44

55
<!-- #docregion mat-badge-size -->
6+
<div matBadge="1" matBadgeSize="small" class="demo-section">Text with small badge</div>
67
<div matBadge="1" matBadgeSize="large" class="demo-section">Text with large badge</div>
78
<!-- #enddocregion mat-badge-size -->
89

910
<div class="demo-section">
1011
Button with a badge on the left
1112
<!-- #docregion mat-badge-position -->
12-
<button mat-raised-button color="primary"
13-
matBadge="8" matBadgePosition="before" matBadgeColor="accent">
13+
<button mat-raised-button matBadge="8" matBadgePosition="before">
1414
Action
1515
</button>
1616
<!-- #enddocregion mat-badge-position -->
@@ -28,7 +28,7 @@
2828
<div class="demo-section">
2929
Icon with a badge
3030
<!-- #docregion mat-badge-color -->
31-
<mat-icon matBadge="15" matBadgeColor="warn">home</mat-icon>
31+
<mat-icon matBadge="15">home</mat-icon>
3232
<!-- #enddocregion mat-badge-color -->
3333
<!-- Include text description of the icon's meaning for screen-readers -->
3434
<span class="cdk-visually-hidden">

src/material/badge/badge.md

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Badges are small status descriptors for UI elements. A badge consists of a small circle,
1+
Badges are small status descriptors for UI elements. A badge consists of a small circle,
22
typically containing a number or other short set of characters, that appears in proximity to
33
another object.
44

@@ -13,40 +13,35 @@ By default, the badge will be placed `above after`. The direction can be changed
1313
the attribute `matBadgePosition` follow by `above|below` and `before|after`.
1414

1515
<!-- example({"example":"badge-overview",
16-
"file":"badge-overview-example.html",
16+
"file":"badge-overview-example.html",
1717
"region":"mat-badge-position"}) -->
1818

1919
The overlap of the badge in relation to its inner contents can also be defined
2020
using the `matBadgeOverlap` tag. Typically, you want the badge to overlap an icon and not
2121
a text phrase. By default it will overlap.
2222

2323
<!-- example({"example":"badge-overview",
24-
"file":"badge-overview-example.html",
24+
"file":"badge-overview-example.html",
2525
"region":"mat-badge-overlap"}) -->
2626

2727
### Badge sizing
2828
The badge has 3 sizes: `small`, `medium` and `large`. By default, the badge is set to `medium`.
29+
30+
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.
31+
2932
You can change the size by adding `matBadgeSize` to the host element.
3033

3134
<!-- example({"example":"badge-overview",
32-
"file":"badge-overview-example.html",
35+
"file":"badge-overview-example.html",
3336
"region":"mat-badge-size"}) -->
3437

3538
### Badge visibility
3639
The badge visibility can be toggled programmatically by defining `matBadgeHidden`.
3740

3841
<!-- example({"example":"badge-overview",
39-
"file":"badge-overview-example.html",
42+
"file":"badge-overview-example.html",
4043
"region":"mat-badge-hide"}) -->
4144

42-
### Theming
43-
Badges can be colored in terms of the current theme using the `matBadgeColor` property to set the
44-
background color to `primary`, `accent`, or `warn`.
45-
46-
<!-- example({"example":"badge-overview",
47-
"file":"badge-overview-example.html",
48-
"region":"mat-badge-color"}) -->
49-
5045
### Accessibility
5146
You must provide a meaningful description via `matBadgeDescription`. When attached to an interactive
5247
element, `MatBadge` applies this description to its host via `aria-describedby`. When attached to

src/material/badge/badge.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ export class _MatBadgeStyleLoader {}
8383
standalone: true,
8484
})
8585
export class MatBadge implements OnInit, OnDestroy {
86-
/** The color of the badge. Can be `primary`, `accent`, or `warn`. */
86+
/**
87+
* The color of the badge. Can be `primary`, `accent`, or `warn`.
88+
* Not recommended in M3, for more information see https://material.angular.io/guide/material-2-theming#optional-add-backwards-compatibility-styles-for-color-variants.
89+
*/
8790
@Input('matBadgeColor')
8891
get color(): ThemePalette {
8992
return this._color;

0 commit comments

Comments
 (0)