使用带有react-select v2的Font Awesome图标?

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

使用:https://react-select.com/home我一直在尝试以下想法的变体:

 const hex = 'f2bc';
 const char = unescape('%u' + hex);
 <Select
   defaultValue={ label: char, value: 'some-value'}
   ...={...}/>

编辑:这是上述尝试的结果:The font awesome icon is not being found

reactjs font-awesome react-select
1个回答
2
投票

react-select很灵活,允许PropTypes.node通过label option

font-awesome图标can be used with className应用于HTMLSpan元素,例如

const labelWithIcon = <span className="fas fa-stroopwafel" />

<Select defaultValue={ label: labelWithIcon, value: 'some-value'} />
© www.soinside.com 2019 - 2024. All rights reserved.