是否可以在Material UI工具提示中添加图标?

问题描述 投票:0回答:1

这是我的代码。我试图在工具提示的title属性中使用材质图标(PhoneInTalk)。但是我的过程似乎不起作用。这是我的输出:enter image description here

//@material-ui/core/styles
const CustomTooltip = withStyles({
  tooltip: {
    color: "tomato",
    backgroundColor: "black",
    fontWeight: "bold",
    fontSize: "12px",
  },
})(Tooltip);

//JSX
<CustomTooltip
        title={`${(<PhoneInTalk />)} Let's talk`}
        placement="top-end"
        arrow
        >
<Avatar className={classes.avatar} src={avatar} alt="Ibrahim Kaiser" />
</CustomTooltip>
reactjs material-ui
1个回答
1
投票

尝试将图标和文本包含在一个片段中。

<CustomTooltip
    title={<><PhoneInTalk /> Let's talk</>}
    placement="top-end"
    arrow
>

检查此示例沙箱link

© www.soinside.com 2019 - 2024. All rights reserved.