You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/material/badge/badge.md
+8-13Lines changed: 8 additions & 13 deletions
Original file line number
Diff line number
Diff 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,
2
2
typically containing a number or other short set of characters, that appears in proximity to
3
3
another object.
4
4
@@ -13,40 +13,35 @@ By default, the badge will be placed `above after`. The direction can be changed
13
13
the attribute `matBadgePosition` follow by `above|below` and `before|after`.
14
14
15
15
<!-- example({"example":"badge-overview",
16
-
"file":"badge-overview-example.html",
16
+
"file":"badge-overview-example.html",
17
17
"region":"mat-badge-position"}) -->
18
18
19
19
The overlap of the badge in relation to its inner contents can also be defined
20
20
using the `matBadgeOverlap` tag. Typically, you want the badge to overlap an icon and not
21
21
a text phrase. By default it will overlap.
22
22
23
23
<!-- example({"example":"badge-overview",
24
-
"file":"badge-overview-example.html",
24
+
"file":"badge-overview-example.html",
25
25
"region":"mat-badge-overlap"}) -->
26
26
27
27
### Badge sizing
28
28
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
+
29
32
You can change the size by adding `matBadgeSize` to the host element.
30
33
31
34
<!-- example({"example":"badge-overview",
32
-
"file":"badge-overview-example.html",
35
+
"file":"badge-overview-example.html",
33
36
"region":"mat-badge-size"}) -->
34
37
35
38
### Badge visibility
36
39
The badge visibility can be toggled programmatically by defining `matBadgeHidden`.
37
40
38
41
<!-- example({"example":"badge-overview",
39
-
"file":"badge-overview-example.html",
42
+
"file":"badge-overview-example.html",
40
43
"region":"mat-badge-hide"}) -->
41
44
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
-
50
45
### Accessibility
51
46
You must provide a meaningful description via `matBadgeDescription`. When attached to an interactive
52
47
element, `MatBadge` applies this description to its host via `aria-describedby`. When attached to
Copy file name to clipboardExpand all lines: src/material/badge/badge.ts
+4-1Lines changed: 4 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -83,7 +83,10 @@ export class _MatBadgeStyleLoader {}
83
83
standalone: true,
84
84
})
85
85
exportclassMatBadgeimplementsOnInit,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.
0 commit comments