0 Tk

Badge

Badge

Badge generates a small badge to the top-right of its child(ren).

Basic badge

Examples of badges containing text, using primary and secondary colors. The badge is applied to its children.

{{ā€œdemoā€: ā€œSimpleBadge.jsā€}}

Color

Use color prop to apply theme palette to component.

{{ā€œdemoā€: ā€œColorBadge.jsā€}}

Customization

Here is an example of customizing the component. You can learn more about this in the overrides documentation page.

{{ā€œdemoā€: ā€œCustomizedBadges.jsā€}}

Badge visibility

The visibility of badges can be controlled using the invisible prop.

{{ā€œdemoā€: ā€œBadgeVisibility.jsā€}}

The badge hides automatically when badgeContent is zero. You can override this with the showZero prop.

{{ā€œdemoā€: ā€œShowZeroBadge.jsā€}}

Maximum value

You can use the max prop to cap the value of the badge content.

{{ā€œdemoā€: ā€œBadgeMax.jsā€}}

Dot badge

The dot prop changes a badge into a small dot. This can be used as a notification that something has changed without giving a count.

{{ā€œdemoā€: ā€œDotBadge.jsā€}}

Badge overlap

You can use the overlap prop to place the badge relative to the corner of the wrapped element.

{{ā€œdemoā€: ā€œBadgeOverlap.jsā€}}

Badge alignment

You can use the anchorOrigin prop to move the badge to any corner of the wrapped element.

{{ā€œdemoā€: ā€œBadgeAlignment.jsā€, ā€œhideToolbarā€: true}}

Accessibility

You can’t rely on the content of the badge to be announced correctly. You should provide a full description, for instance, with aria-label:

{{ā€œdemoā€: ā€œAccessibleBadges.jsā€}}