我在我的 react 应用程序中使用样式组件 我想添加标题属性(用于工具提示) 应用于我的样式组件
我尝试使用包装 div html 元素并在其上应用标题标签,但无法做到这一点,也尝试使用 css`` 样式组件帮助程序无法做到这一点。
my styled components: (with ellipsis):
const FilterTitle = styled.div`
display: inline-block;
width: 100%;
line-height: 40px;
height: 40px;
color: ${blackChosen};
font-family: Poppins;
font-size: 16px;
letter-spacing: 0.15px;
padding-left: 15px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
font-weight: ${props => (props.chosen) ? '500' : 'initial'};
`;
and:
<FilterTitle> I might be a long sentence shown with ... and the title tag should tooltip me</FilterTitle>
最佳答案
<FilterTitle>
仍在渲染 div
因此您可以将任何您想要的属性直接放在该组件上,它们将被传递到 div:
<FilterTitle title="A long sentence, eh?">...
关于css - 如何在 react 样式组件中添加 'title' 标签(用于工具提示),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56259123/