我想将我的 MUI 工具提示的背景颜色设置为红色,文本颜色设置为白色。

huangapple go评论61阅读模式
英文:

I want to set the background color of my mui Tooltip to Red and text color to White

问题

<Tooltip
  placement="left"
  classes={{
    tooltip: "classes.customTooltip",
    arrow: "classes.customArrow",
  }}
  title="Reverse POS Update"
  arrow
>
  <IconButton aria-label="edit" onClick={() => handleEdit(params.id)}>
    <SyncAltRoundedIcon className="reversebtn" />
  </IconButton>
</Tooltip>
{
  field: "TickToDelete",
  headerName: "Delete",
  width: 70,
  sortable: true,
  renderCell: (params) => {
    return (
      <Tooltip title="Delete" placement="right">
        <IconButton aria-label="edit" onClick={() => handleEdit(params.id)}>
          <DeleteIcon />
        </IconButton>
      </Tooltip>
    );
  },
}
英文:
`&lt;Tooltip
        placement=&quot;left&quot;
        classes={{
          tooltip: &quot;classes.customTooltip&quot;,
          arrow: &quot;classes.customArrow&quot;,
        }}
        title=&quot;Reverse POS Update&quot;
        arrow
      &gt;
        &lt;IconButton aria-label=&quot;edit&quot; onClick={() =&gt; handleEdit(params.id)}&gt;
          &lt;SyncAltRoundedIcon className=&quot;reversebtn&quot; /&gt;
        &lt;/IconButton&gt;
      &lt;/Tooltip&gt;`    

I am Using Datagrid and in one of the column i used and icon instead of button and i apply a tooltip of mui on hover and my icon is of red color and i also want my tooltip to be red.

{
field: &quot;TickToDelete&quot;,
headerName: &quot;Delete&quot;,
width: 70,
sortable: true,
renderCell: (params) =&gt; {
return (
&lt;Tooltip title=&quot;Delete&quot; placement=&quot;right&quot;&gt;
&lt;IconButton aria-label=&quot;edit&quot; onClick={() =&gt; handleEdit(params.id)}&gt;
&lt;DeleteIcon /&gt;
&lt;/IconButton&gt;
&lt;/Tooltip&gt;
);
},
},

答案1

得分: 2

MUI5中,您可以使用componentsProps自定义<Tooltip/>的样式。查看下面的示例 👇

<Tooltip
  title="Delete"
  open={true}
  componentsProps={{
    tooltip: {
      sx: {
        bgcolor: "red",
        color: "white"
      }
    }
  }}
>

希望这对您有所帮助。

英文:

In MUI5, You can customize styling of &lt;Tooltip/&gt; using componentsProps. Check the example below 👇

&lt;Tooltip
  title=&quot;Delete&quot;
  open={true}
  componentsProps={{
    tooltip: {
      sx: {
        bgcolor: &quot;red&quot;,
        color: &quot;white&quot;
      }
    }
  }}
&gt;

huangapple
  • 本文由 发表于 2023年2月24日 15:20:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/75553603.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定