Badge
Badge generates a small badge to the top-right of its child(ren).
Usage guidelines
- Use badges for supplemental status: Use badges for short counts or compact states that update an existing control or item, such as unread messages on an inbox button. If the status is important on its own, show it in the UI instead of relying only on the badge.
- Label the element that owns the badge: A badge is a visual cue tied to another
element, so its meaning should be part of that element's accessible name. For example,
use
aria-label="Inbox, 4 unread messages"instead ofaria-label="Inbox"on the target element. - Use dot badges for simple states: A dot badge does not show text or a number, so use
it only when the surrounding UI makes the state clear, such as
OnlineorUnread.
This demo applies the same pattern to a ListItemButton with a Badge: the visible
count is included in the item's accessible name so it's announced in the context of the
surrounding UI.
Badge content
Use badgeContent to add a short count or label to the wrapped element.
Dot badge
Use variant="dot" for a compact status indicator without a count.
Visibility
Control badge visibility with the invisible prop.
The badge hides automatically when badgeContent is zero. Override this with the showZero
prop when zero is meaningful to the interface.
Maximum value
Use the max prop to cap large numeric values.
Badge alignment
Use the anchorOrigin prop to move the badge to any corner of the wrapped element.
<IconButton aria-label="show 12 unread messages">
<Badge
badgeContent={12}
color="secondary"
anchorOrigin={{
vertical: 'top',
horizontal: 'right',
}}
>
<MailIcon />
</Badge>
</IconButton>Badge overlap
Use the overlap prop when the wrapped element is circular.
Custom styles
Use theme style overrides, the sx prop, or styled() to customize the badge.
Learn more in the customization guide.