/
githubmirror
/
material-ui
Обзор
Документация
Войти
/
githubmirror
/
material-ui
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
docs/data/material/components/badges/BadgeIntro.js
32 строки
879 B
Albert Yu
[badge] Add `aria-hidden` to badge content and polish docs demos (#48471)
03 июн 2026, 15:57
Не верифицирован
03 июн 2026, 15:57
49aade9
Код
Авторство
О чём код?
import IconButton from '@mui/material/IconButton'; import Badge from '@mui/material/Badge'; import MailIcon from '@mui/icons-material/Mail'; const maxVisibleNotifications = 99; const unreadNotificationsCount = 100; function getUnreadNotificationsLabel(count) { if (count === 0) { return 'show no unread notifications'; } if (count > maxVisibleNotifications) { return `show more than ${maxVisibleNotifications} unread notifications`; } return `show ${count} unread notification${count === 1 ? '' : 's'}`; } export default function BadgeIntro() { const label = getUnreadNotificationsLabel(unreadNotificationsCount); return ( <IconButton aria-label={label}> <Badge badgeContent={unreadNotificationsCount} color="secondary" max={maxVisibleNotifications} > <MailIcon /> </Badge> </IconButton> ); }