-
-
Notifications
You must be signed in to change notification settings - Fork 52.2k
Use React SVG components for icons instead of an icon font #10353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@yesmeck you asked me to open this issue in #7809 (comment), is there something I can do to make it move forward? Thanks ;) |
@tibdex I will open a discussion at our internal weekly meeting |
Here is the summary of our meeting:
We will start the work when our designers finish the re-making. |
@tibdex thank you so much for getting this started. Offline access is critical for our application (we have an Electron desktop version that needs to operate for extended periods of time without Internet access). Thanks, @yesmeck for seeing the importance of this enhancement! I look forward to it being integrated. |
Thank you so much for the awesome library Ant Design team! We really appreciate all the amazing work you are doing. Hoping this is something that can happen soon. Is there an update on whether this is going to happen, and if so when it will happen? |
Congrats on the 3.7.0 release, it's great! @HeskeyBaozi and @yesmeck do you have any update to share on this ticket? Can we help you move forward? |
We're upgrading the |
@kazup01 funded this issue with $10. Visit this issue on Issuehunt |
The corresponding PR is #11322 for those who want to follow the progress. Thanks for working on this @HeskeyBaozi 😉! |
Is this coming to the Angular implementation as well? |
For those folks looking to override the icons with local copies to prevent the callout to the alicdn, I found this after much digging and got it working: https://www.npmjs.com/package/antd-local-icon |
Published with 3.9.0! |
@afc163 使用svg后,打包的js大小翻倍了,之前使用fonticon,打包出来600K+,现在1200+了 |
@zlab 可以单独提一个 issue。 |
@loadbalance-sudachi-kun funded this issue with $256. Visit this issue on Issuehunt |
@afc163 has started working. Visit this issue on Issuehunt |
@afc163 has submitted output. Visit this issue on Issuehunt |
@afc163 has rewarded. Visit this issue on Issuehunt |
如果我在Icon上使用了 id属性 在设置点击事件后 无法通过e.target.id来获取?请问这个问题如何解决? |
svg图标在IE edge下可被聚焦。导致Select组件单选模式在通过tab导航时必须按两次才能切换。采用svg显示的组件应该都存在这种情况。是否应该对svg使用focusable=false去规避呢? |
@1993klk 来个 PR |
使用了Icon.createFromIconfontCN方法之后,引用的antd design 自带的图标变成了两个,是什么原因呢 |
开个 issue,发重现看看哈~ |
引用了多个版本的 antd 样式的问题。 |
请问一下怎么实现icon图标的style不支持font-weight吗,怎么让他变粗呢 |
你可以使用e.currentTarget.id来获取,因为编译时可能层级之间被添加了别的层级 |
我想问下2.1.2版本如何扩展自定义SVG图标,我发现官方文档是错的 |
createFromIconfontCN能不能提供一个引用本地文件的属性,而不是引用网上资源,有些项目是不同外网的 |
使用 SVG 图标替换 font 图标后,想要循环生成结构(比如menu菜单)时,怎么循环生成对应菜单不同的图标呢?有实现过的伙伴么 |
@xingorg1 这个可能得看看 vue 文档 |
求助:如何使用类似require.context()类似的API来批量导入svg,然后导出自定义的Icon组件 |
对于你所有需要用到的icon是已知的吗? |
对,本地的 |
把这些需要的都import 进来. 编成一个map, 菜单循环的时候用 |
现在就是单个文件导入的,想找一个自动化的方法,省得以后多了不好维护😂 |
antd vue 2.x 版本的图标怎么按需引用,找遍全网也没有,通过cdn的方式引入也没有 |
This issue is a continuation of the discussion on #7809.
What problem does this feature solve?
The goal is, in one of the future Ant Design minor/bugfix releases, to stop using an icon font by implementing icons as React SVG components instead.
There are multiple articles explaining how SVGs are better than icon fonts:
What does the proposed API look like?
There are two main features to preserve to be able to make the switch without introducing breaking changes:
<Icon />
'sstyle
prop to change the icons size and color. In particular, the CSS propertiesfont-size
,line-height
andcolor
should work as expected. Align SVG Icons to Text and Say Goodbye to Font Icons explains how it's possible to maintain this behaviour with SVG icons.type
prop to the<Icon />
component should be enough to render the correct icon. To keep this working, we would write one React component per existing icon, import them all in<Icon />
's module, and have aswitch
in<Icon />
'srender
method to display the right icon based on thetype
prop. It would slightly increase the JS bundle size but I think it's worth it as:In the long term, to make sure only used icons end up in the final application bundle, we could stop using the
<Icon type="link" />
component and expose all the icons as separate modules like Material UI does. We could also export all these separate icon modules from a singleantd/icons.js
and then leverage the existing babel-plugin-import technique to offer theimport {Link} from 'antd/icons';
syntax sugar without weighing the final application size down.What do you think? Can we make the switch without waiting for Ant Design 4?
The text was updated successfully, but these errors were encountered: