如何修改工具提示组件的字体大小/样式? [英] How to modify font-size/style of Tooltip component?
问题描述
无法将自定义类分配给工具提示组件以更新工具提示组件的样式
Not able to assign custom class to tooltip component in order to update the style of tooltip component
尝试通过分配给类属性
发布在 https://codesandbox.io/s/twilight-fire-907mp
推荐答案
使用自定义样式制作您自己的工具提示,然后使用它:
Make your own Tooltip with custom styles and then use it:
const TooltipWithBiggerFontSize = withStyles({
tooltip: {
fontSize: 30
}
})(Tooltip)
就像您对其他组件所做的一样,例如:DialogContent
或DialogActions
.
As you already did with other components, eg: DialogContent
or DialogActions
.
用法
<TooltipWithBiggerFontSize title="Custom Search">
<Publish />
</TooltipWithBiggerFontSize>
顺便说一句,您的代码令人困惑.您正在混合功能组件和类组件.一次,您将使用makeStyles
进行一次样式化.
您应该选择一种方法并坚持下去.这是文档的样式.它将解决您的大多数问题.
BTW, your code is confusing. You are mixing functional and class components. Once, you are styling with withStyles
once with makeStyles
.
You should choose one method and stick to it. Here is styling docs. It will solve most of your problems.
这篇关于如何修改工具提示组件的字体大小/样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!