How to change the background color of MUI tooltips?
P粉147045274
2023-09-04 11:56:50
<p>I would like a "?" user can hover over the icon and get specifications on what data should be entered in the text field. MUI's default hover is gray with white text, but I want mine to be white with gray text and with a larger font. I found that using works fine for font size and color, but when I change the background color, the hover text field has a gray border around it. This is the hover.js component: </p>
<pre class="brush:php;toolbar:false;">export default function HoverTip(prop) {
const { tip } = prop
return (
<Tooltip
title={
<Typography
fontSize={15}
backgroundColor={'#ffff'}
color={'#514E6A'}>
{tip}
</Typography>}
arrow
placement="right"
sx={{fontSize: '30'}}
>
<IconButton>
<HelpOutlineIcon />
</IconButton>
</Tooltip>
)
}</pre>
<p>However, this leaves a black border around the hover text box. Any idea how to solve this problem?
What does it look like</p>
You can use
sx
to solve this problem.Now I found that using it directly on the
Tooltip
doesn't work, but you can useslotProps
to pass it to the actualtooltip
element property.