Skip to content

useBadge API

API reference docs for the useBadge hook. Learn about the input parameters and other APIs of this exported module.

Demos

For examples and details on the usage of this React hook, visit the demo pages:

Import

import useBadge from '@mui/base/useBadge';

Parameters

NameTypeDefaultDescription
badgeContentReact.ReactNode
The content rendered within the badge.
invisiblebooleanfalse
If true, the badge is invisible.
maxnumber99
Max count to show.
showZerobooleanfalse
Controls whether the badge is hidden when badgeContent is zero.

Return value

NameTypeDefaultDescription
badgeContentReact.ReactNode
Defines the content that's displayed inside the badge.
displayValueReact.ReactNodebadgeContent
Value to be displayed in the badge. If badgeContent is greater than max, it will return max+.
invisiblebooleanfalse
If true, the component will not be visible.
maxnumber99
Maximum number to be displayed in the badge.