element icon indicating copy to clipboard operation
element copied to clipboard

在后续版本中,Icon组件是否考虑支持font-awesome图标?

Open forcszhangguoyu opened this issue 10 years ago • 24 comments

目前的ICON数量有限,在后续版本中,Icon组件是否考虑支持font-awesome图标,以弥补目前图标不足的情况?

forcszhangguoyu avatar Nov 14 '16 06:11 forcszhangguoyu

没必要加进来吧,自己安装 font-awesome 不是一样么

QingWei-Li avatar Nov 14 '16 06:11 QingWei-Li

那么,像Input 组件然后使用fa的图标呢?

forcszhangguoyu avatar Nov 14 '16 06:11 forcszhangguoyu

如果这样的话可以考虑做成另一个插件,作用就是把其他图标库的 icon 的命名规则改成 element icon 的

QingWei-Li avatar Nov 14 '16 06:11 QingWei-Li

这个方案有考虑过,但是感觉这样修改代码不友好,建议支持fa,或者提供扩展第三方图标库的方案,谢谢!

forcszhangguoyu avatar Nov 14 '16 06:11 forcszhangguoyu

肯定不用直接改代码,我考虑下写一个吧

QingWei-Li avatar Nov 14 '16 08:11 QingWei-Li

我看了下 fa 是有提供 Less 和 Sass 版本的,那么完全可以自己 build 一份,我简单写了个 Less 的

[class^="el-icon-fa"], [class*=" el-icon-fa"] {
  display: inline-block;
  font: normal normal normal 14px/1 FontAwesome!important;
  font-size: inherit;
  text-rendering: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@import url("../node_modules/font-awesome/less/font-awesome");
@fa-css-prefix: el-icon-fa;

这样就可以在 Element 里使用了,例如 input 就可以写成

<el-input icon="fa-check" />

感觉没必要写成插件了

QingWei-Li avatar Nov 14 '16 10:11 QingWei-Li

@QingWei-Li 可以考虑放到 FAQ 里面去。

furybean avatar Nov 14 '16 13:11 furybean

Icon可以支持iconmoon搜集的svg图标吗?怎么使用呢?

michaellyu avatar Nov 18 '16 09:11 michaellyu

https://github.com/ElemeFE/element/issues/1054#issuecomment-260294522 the code snippet is not working . did you tested it ?

ghost avatar Feb 18 '17 06:02 ghost

我按照这种方式实现,图标还是出不来

ruixiu avatar Apr 27 '17 06:04 ruixiu

按照@QingWei-LI给的方式,在input中使用图标显示小方块,在i标签中使用class="el-icon-fa-user"显示也是小方块。如果把fa-css-prefix改为el-iconfa,在i标签中使用class="el-iconfa-user"正常,input仍然无效。望解答

ruixiu avatar Apr 27 '17 06:04 ruixiu

搞定了,这样写

<template>
  <div id="app">
    <transition name="fade" mode="out-in">
      <router-view></router-view>
    </transition>
  </div>
</template>

<script>
export default {
}
</script>

<style lang="less">
  [class^="el-icon-fa"], [class*=" el-icon-fa"] {
    font-family:"FontAwesome" !important;
    display: inline-block;
    font-size: inherit;
    text-rendering: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  @import url("../node_modules/font-awesome/less/font-awesome");
  @fa-css-prefix: el-icon-fa;
# **必须在最后,不然图标出不来**
  @import url("../node_modules/element-ui/lib/theme-default/index.css");
</style>

ruixiu avatar Apr 27 '17 07:04 ruixiu

what if I just use elementui by including the css file, how can I use fontawesome with elementUI? I try this <i class="fa fa-refresh fa-1" aria-hidden="true"></i> however it just shows a empty square in the button..like @ruixiu had mentioned.

allanruin avatar Jul 11 '17 05:07 allanruin

any news about this issue ? I am not using this project because of this problem .

osman-mohamad avatar Aug 09 '17 12:08 osman-mohamad

A demo: https://github.com/ElementUI/element-font-awesome

Leopoldthecoder avatar Aug 10 '17 09:08 Leopoldthecoder

thank you @Leopoldthecoder

osman-mohamad avatar Aug 11 '17 03:08 osman-mohamad

sass 怎么弄? 也是没出来

maimake avatar Aug 19 '17 16:08 maimake

@maimake

<style lang="scss">
  i[class^="el-icon-fa"], i[class*=" el-icon-fa"] {
    font-family:"FontAwesome" !important;
    display: inline-block;
    font-size: inherit;
    text-rendering: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  $fa-font-path: "~font-awesome/fonts";
  $fa-css-prefix: "el-icon-fa";

  @import "~font-awesome/scss/font-awesome.scss";
</style>

Wizard67 avatar Aug 20 '17 17:08 Wizard67

@Wizard67 you should create a repo or include this in the official doc, great help, thanks

WangHansen avatar Sep 25 '17 21:09 WangHansen

2.0之后的版本有点已经不支持https://github.com/ElementUI/element-font-awesome中的写法了

qinaichen avatar Dec 06 '17 14:12 qinaichen