1e41f4b71Sopenharmony_ci# badge
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci>  **NOTE**
4e41f4b71Sopenharmony_ci>
5e41f4b71Sopenharmony_ci>  This component is supported since API version 5. Updates will be marked with a superscript to indicate their earliest API version.
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ciThe **\<badge>** component is used to mark new events that require user attention in your application.
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci## Required Permissions
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ciNone
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ci## Child Components
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ciThis component supports only one child component.
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci>  **NOTE**
20e41f4b71Sopenharmony_ci>
21e41f4b71Sopenharmony_ci>  If multiple child components are used, only the first one takes effect by default.
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci
24e41f4b71Sopenharmony_ci## Attributes
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ciIn addition to the [universal attributes](js-components-common-attributes.md), the following attributes are supported.
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ci| Name              | Type       | Default Value  | Mandatory| Description                                                        |
29e41f4b71Sopenharmony_ci| ------------------ | ----------- | -------- | ---- | ------------------------------------------------------------ |
30e41f4b71Sopenharmony_ci| placement          | string      | rightTop | No  | Position of a number or dot badge. Available values are as follows:<br>- **right**: on the right border of the component.<br>- **rightTop**: in the upper right corner of the component border.<br>- **left**: on the left border of the component.|
31e41f4b71Sopenharmony_ci| count              | number      | 0        | No  | Number of notifications displayed via the badge. If the value is 0 (default value), the badge is not displayed. If the value is greater than 0, the badge is a number badge.<br>When the **count** value is greater than the **maxcount** value, *maxcount***+** is displayed. The largest integer value supported for **count** is **2147483647**.|
32e41f4b71Sopenharmony_ci| visible            | boolean     | false    | No  | Whether to display the badge. The value **true** means that the badge shows up when a new notification is received. To use a number badge, also set the **count** attribute.|
33e41f4b71Sopenharmony_ci| maxcount           | number      | 99       | No  | Maximum number of notifications. When the number of new notifications exceeds the value of this attribute, *maxcount***+** is displayed, for example, **99+**.<br>The largest integer value supported for **maxcount** is **2147483647**.|
34e41f4b71Sopenharmony_ci| config             | BadgeConfig | -        | No  | Configuration of the badge.                                |
35e41f4b71Sopenharmony_ci| label<sup>6+</sup> | string      | -        | No  | Text of the new notification displayed via the badge.<br>When this attribute is set, attributes **count** and **maxcount** do not take effect.|
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ci**Table 1** BadgeConfig
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ci| Name        | Type            | Default Value     | Mandatory  | Description          |
40e41f4b71Sopenharmony_ci| ---------- | -------------- | -------- | ---- | ------------ |
41e41f4b71Sopenharmony_ci| badgeColor | &lt;color&gt;  | \#fa2a2d | No   | Background color of the badge.   |
42e41f4b71Sopenharmony_ci| textColor  | &lt;color&gt;  | \#ffffff | No   | Text color of the number badge.|
43e41f4b71Sopenharmony_ci| textSize   | &lt;length&gt; | 10px     | No   | Text size of the number badge.|
44e41f4b71Sopenharmony_ci| badgeSize  | &lt;length&gt; | 6px      | No   | Default size of the dot badge.   |
45e41f4b71Sopenharmony_ci
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ci## Styles
48e41f4b71Sopenharmony_ci
49e41f4b71Sopenharmony_ciThe [universal styles](js-components-common-styles.md) are supported.
50e41f4b71Sopenharmony_ci
51e41f4b71Sopenharmony_ci>  **NOTE**
52e41f4b71Sopenharmony_ci>
53e41f4b71Sopenharmony_ci>  The total size of child components must be smaller than or equal to that of the **\<badge>** component. Otherwise, the child components cannot be displayed.
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ci
56e41f4b71Sopenharmony_ci## Events
57e41f4b71Sopenharmony_ci
58e41f4b71Sopenharmony_ciThe [universal events](js-components-common-events.md) are supported.
59e41f4b71Sopenharmony_ci
60e41f4b71Sopenharmony_ci
61e41f4b71Sopenharmony_ci## Methods
62e41f4b71Sopenharmony_ci
63e41f4b71Sopenharmony_ciThe [universal methods](js-components-common-methods.md) are supported.
64e41f4b71Sopenharmony_ci
65e41f4b71Sopenharmony_ci
66e41f4b71Sopenharmony_ci## Example
67e41f4b71Sopenharmony_ci
68e41f4b71Sopenharmony_ci```html
69e41f4b71Sopenharmony_ci<!-- xxx.hml -->
70e41f4b71Sopenharmony_ci<div class="container">
71e41f4b71Sopenharmony_ci  <badge class="badge" config="{{badgeconfig}}" visible="true" count="100" maxcount="99">
72e41f4b71Sopenharmony_ci    <text class="text1">example</text>
73e41f4b71Sopenharmony_ci  </badge>
74e41f4b71Sopenharmony_ci  <badge class="badge" visible="true" count="0">
75e41f4b71Sopenharmony_ci    <text class="text2">example</text>
76e41f4b71Sopenharmony_ci  </badge>
77e41f4b71Sopenharmony_ci</div>
78e41f4b71Sopenharmony_ci```
79e41f4b71Sopenharmony_ci
80e41f4b71Sopenharmony_ci```css
81e41f4b71Sopenharmony_ci/* xxx.css */
82e41f4b71Sopenharmony_ci.container {
83e41f4b71Sopenharmony_ci  flex-direction: column;
84e41f4b71Sopenharmony_ci  width: 100%;
85e41f4b71Sopenharmony_ci  align-items: center;
86e41f4b71Sopenharmony_ci}
87e41f4b71Sopenharmony_ci.badge {
88e41f4b71Sopenharmony_ci  width: 50%;
89e41f4b71Sopenharmony_ci  margin-top: 100px;
90e41f4b71Sopenharmony_ci}
91e41f4b71Sopenharmony_ci.text1 {
92e41f4b71Sopenharmony_ci  background-color: #f9a01e;
93e41f4b71Sopenharmony_ci  font-size: 50px;
94e41f4b71Sopenharmony_ci}
95e41f4b71Sopenharmony_ci.text2 {
96e41f4b71Sopenharmony_ci  background-color: #46b1e3;
97e41f4b71Sopenharmony_ci  font-size: 50px;
98e41f4b71Sopenharmony_ci}
99e41f4b71Sopenharmony_ci```
100e41f4b71Sopenharmony_ci
101e41f4b71Sopenharmony_ci```js
102e41f4b71Sopenharmony_ci// xxx.js
103e41f4b71Sopenharmony_ciexport default {
104e41f4b71Sopenharmony_ci  data:{
105e41f4b71Sopenharmony_ci    badgeconfig:{
106e41f4b71Sopenharmony_ci      badgeColor:"#0a59f7",
107e41f4b71Sopenharmony_ci      textColor:"#ffffff",
108e41f4b71Sopenharmony_ci    }
109e41f4b71Sopenharmony_ci  }
110e41f4b71Sopenharmony_ci}
111e41f4b71Sopenharmony_ci```
112e41f4b71Sopenharmony_ci
113e41f4b71Sopenharmony_ci![en-us_image_000000117726526811](figures/en-us_image_000000117726526811.png)
114