/
githubmirror
/
material-ui
Обзор
Документация
Войти
/
githubmirror
/
material-ui
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
docs/data/material/components/tooltips/CustomizedTooltips.js
69 строк
2 KB
Siriwat K
[material-ui][system] Remove deprecated system props from Box, Stack, Typography (#48072)
25 мар 2026, 05:44
Не верифицирован
25 мар 2026, 05:44
8663368
Код
Авторство
О чём код?
import * as React from 'react'; import { styled } from '@mui/material/styles'; import Button from '@mui/material/Button'; import Tooltip, { tooltipClasses } from '@mui/material/Tooltip'; import Typography from '@mui/material/Typography'; const LightTooltip = styled(({ className, ...props }) => ( <Tooltip describeChild {...props} classes={{ popper: className }} /> ))(({ theme }) => ({ [`& .${tooltipClasses.tooltip}`]: { backgroundColor: theme.palette.common.white, color: 'rgba(0, 0, 0, 0.87)', boxShadow: theme.shadows[1], fontSize: 11, }, })); const BootstrapTooltip = styled(({ className, ...props }) => ( <Tooltip describeChild {...props} arrow classes={{ popper: className }} /> ))(({ theme }) => ({ [`& .${tooltipClasses.arrow}`]: { color: theme.palette.common.black, }, [`& .${tooltipClasses.tooltip}`]: { backgroundColor: theme.palette.common.black, }, })); const HtmlTooltip = styled(({ className, ...props }) => ( <Tooltip describeChild {...props} classes={{ popper: className }} /> ))(({ theme }) => ({ [`& .${tooltipClasses.tooltip}`]: { backgroundColor: '#f5f5f9', color: 'rgba(0, 0, 0, 0.87)', maxWidth: 220, fontSize: theme.typography.pxToRem(12), border: '1px solid #dadde9', }, })); export default function CustomizedTooltips() { return ( <div> <LightTooltip title="Add"> <Button>Light</Button> </LightTooltip> <BootstrapTooltip title="Add"> <Button>Bootstrap</Button> </BootstrapTooltip> <HtmlTooltip title={ <React.Fragment> <Typography sx={{ color: 'inherit', }} > Tooltip with HTML </Typography> <em>{"And here's"}</em> <b>{'some'}</b> <u>{'amazing content'}</u>.{' '} {"It's very engaging. Right?"} </React.Fragment> } > <Button>HTML</Button> </HtmlTooltip> </div> ); }