ion-badge
Badges are inline block elements that usually appear near another element. Typically they contain a number or other characters. They can be used as a notification that there are additional items associated with an element and indicate how many items there are. Badges are hidden if no content is passed in.
Basic Usage
<ion-list>
<ion-item>
<ion-badge slot="start">11</ion-badge>
<ion-label>Badge in start slot</ion-label>
</ion-item>
<ion-item>
<ion-badge slot="end">22</ion-badge>
<ion-label>Badge in end slot</ion-label>
</ion-item>
</ion-list>
Theming
Colors
<ion-list>
<ion-item>
<ion-label>Followers</ion-label>
<ion-badge color="primary">22k</ion-badge>
</ion-item>
<ion-item>
<ion-label>Likes</ion-label>
<ion-badge color="secondary">118k</ion-badge>
</ion-item>
<ion-item>
<ion-label>Stars</ion-label>
<ion-badge color="tertiary">34k</ion-badge>
</ion-item>
<ion-item>
<ion-label>Completed</ion-label>
<ion-badge color="success">80</ion-badge>
</ion-item>
<ion-item>
<ion-label>Warnings</ion-label>
<ion-badge color="warning">70</ion-badge>
</ion-item>
<ion-item>
<ion-label>Notifications</ion-label>
<ion-badge color="danger">1000</ion-badge>
</ion-item>
</ion-list>
CSS Properties
- src/app/example.component.html
- src/app/example.component.css
<ion-list>
<ion-item>
<ion-label>Badges styled</ion-label>
<ion-badge>1</ion-badge>
</ion-item>
</ion-list>
Properties
color
Description | The color to use from your application's color palette. Default options are: "primary" , "secondary" , "tertiary" , "success" , "warning" , "danger" , "light" , "medium" , and "dark" . For more information on colors, see theming. |
Attribute | color |
Type | "danger" | "dark" | "light" | "medium" | "primary" | "secondary" | "success" | "tertiary" | "warning" | string & Record<never, never> | undefined |
Default | undefined |
mode
Description | The mode determines which platform styles to use. |
Attribute | mode |
Type | "ios" | "md" |
Default | undefined |
Events
No events available for this component.
Methods
No public methods available for this component.
CSS Shadow Parts
No CSS shadow parts available for this component.
CSS Custom Properties
Name | Description |
---|---|
--background | Background of the badge |
--color | Text color of the badge |
--padding-bottom | Bottom padding of the badge |
--padding-end | Right padding if direction is left-to-right, and left padding if direction is right-to-left of the badge |
--padding-start | Left padding if direction is left-to-right, and right padding if direction is right-to-left of the badge |
--padding-top | Top padding of the badge |
Slots
No slots available for this component.