Skip to content

Commit d0d41b6

Browse files
authored
Merge pull request #6453 from IgniteUI/badge-update
fix(badge): clarifying the usage of badge value and icon
2 parents 3c6c0cf + c769281 commit d0d41b6

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

en/components/badge.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,31 @@ igx-badge {
137137
}
138138
```
139139

140+
### Badge Value and Icon
141+
142+
Use the `[value]` input to display text or a numeric count inside the badge. This is the recommended approach instead of projecting content directly:
143+
144+
```html
145+
<!-- Recommended -->
146+
<igx-badge [value]="model.value"></igx-badge>
147+
148+
<!-- Avoid -->
149+
<igx-badge>{{ model.value }}</igx-badge>
150+
```
151+
152+
When both `[icon]` and `[value]` are set, the badge displays both simultaneously:
153+
154+
```html
155+
<!-- Both the icon "check" and the value "5" will be shown -->
156+
<igx-badge icon="check" value="5" type="success"></igx-badge>
157+
```
158+
159+
To display only a numeric value without an icon, make sure `[icon]` is not set:
160+
161+
```html
162+
<igx-badge [value]="unreadCount" type="info"></igx-badge>
163+
```
164+
140165
### Badge Icon
141166

142167
In addition to material icons, the `igx-badge` component also supports usage of [Material Icons Extended](../components/material-icons-extended.md) and any other custom icon set. To add an icon from the material icons extended set inside your badge component, first you have to register it:
@@ -194,7 +219,7 @@ export class AppModule {}
194219
```
195220

196221
>[!NOTE]
197-
>The [`igx-badge`]({environment:angularApiUrl}/classes/igxbadgecomponent.html) has [`icon`]({environment:angularApiUrl}/classes/igxbadgecomponent.html#icon) and [`type`]({environment:angularApiUrl}/classes/igxbadgecomponent.html#type) inputs to configure the badge look. You can set the icon by providing its name from the official [material icons set](https://material.io/icons/). The badge type can be set to either [`default`]({environment:angularApiUrl}/enums/type.html#default), [`info`]({environment:angularApiUrl}/enums/type.html#info), [`success`]({environment:angularApiUrl}/enums/type.html#success), [`warning`]({environment:angularApiUrl}/enums/type.html#warning), or [`error`]({environment:angularApiUrl}/enums/type.html#error). Depending on the type, a specific background color is applied.
222+
>The [`igx-badge`]({environment:angularApiUrl}/classes/igxbadgecomponent.html) has [`icon`]({environment:angularApiUrl}/classes/igxbadgecomponent.html#icon), [`value`]({environment:angularApiUrl}/classes/igxbadgecomponent.html#value), and [`type`]({environment:angularApiUrl}/classes/igxbadgecomponent.html#type) inputs to configure the badge look. You can set the icon by providing its name from the official [material icons set](https://material.io/icons/). The badge type can be set to either [`default`]({environment:angularApiUrl}/enums/type.html#default), [`info`]({environment:angularApiUrl}/enums/type.html#info), [`success`]({environment:angularApiUrl}/enums/type.html#success), [`warning`]({environment:angularApiUrl}/enums/type.html#warning), or [`error`]({environment:angularApiUrl}/enums/type.html#error). Depending on the type, a specific background color is applied.
198223
199224
In our sample, [`icon`]({environment:angularApiUrl}/classes/igxbadgecomponent.html#icon) and [`type`]({environment:angularApiUrl}/classes/igxbadgecomponent.html#type) are bound to model properties named _icon_ and _type_.
200225

0 commit comments

Comments
 (0)