[英]How to put the text inside react-icons component?
I have an icon as a component, I need to put the text inside of it.我有一个图标作为组件,我需要将文本放入其中。 Here is what I have:
这是我所拥有的:
<span className={s['manaBtn']}>
<FiHexagon /><span className={s['manaBtn__text']}>{props.value}</span>
</span>
The styles款式
.manaBtn {
position: relative;
&__text {
position: absolute;
top: 0;
left: 0;
transform: translate(50%, -50%);
z-index: 2;
}
}
The result结果
It is not about the styling, I can apply it on my own.
这与造型无关,我可以自己应用。 I'm asking is there a way to make this values as children or smth like this.
我在问有没有办法让这些价值观像孩子一样或像这样。
Create a new component:创建一个新组件:
const customIcon = props => {
return (
<div>
<FiHexagon/>
<div>props.value</div>
</div>
)
}
Style the divs according to your needs.根据您的需要设置 div 样式。
Then pass value
as a prop: <customIcon value=0/>
然后将
value
作为 prop 传递: <customIcon value=0/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.