You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

124 lines
2.5 KiB

---
category: Components
chinese: 图标
type: Basic
english: Icon
toc: false
---
10 years ago
10 years ago
有含义的矢量图形,每一个图标打倒一个敌人。
## 图标的命名规范
我们为每个图标赋予了语义化的命名,命名规则如下:
10 years ago
- 实心和描线图标保持同名,用 `-o` 来区分,比如 `question-circle`(实心) 和 `question-circle-o`(描线);
9 years ago
- 命名顺序:`[icon名]-[形状可选]-[描线与否]-[方向可选]`。
## 如何使用
使用 `<Icon />` 标签声明组件,指定图标对应的 type 属性,示例代码如下:
```html
<Icon type="link" />
```
最终会渲染为:
10 years ago
```html
<i class="anticon anticon-${type}"></i>
10 years ago
```
## 本地部署
图标组件使用 [iconfont.cn](http://iconfont.cn),默认公网可访问。如需本地部署,可参考 [示例](https://github.com/ant-design/antd-init/tree/master/examples/local-iconfont)。
10 years ago
## 图标列表
> 点击图标复制代码。
8 years ago
### 方向性图标
```__react
import IconSet from 'site/theme/template/IconSet';
ReactDOM.render(<IconSet className="icons" catigory="direction" />, mountNode);
```
8 years ago
### 提示建议性图标
```__react
ReactDOM.render(<IconSet className="icons" catigory="suggestion" />, mountNode);
```
8 years ago
### 网站通用图标
```__react
ReactDOM.render(<IconSet className="icons" catigory="other" />, mountNode);
```
<style>
.markdown .icons {
width: 100%;
}
ul.anticons-list {
8 years ago
margin: 40px 0;
list-style: none;
overflow: hidden;
}
10 years ago
ul.anticons-list li {
float: left;
8 years ago
width: 16.66%;
text-align: center;
list-style: none;
cursor: pointer;
height: 100px;
8 years ago
color: #555;
transition: all 0.2s ease;
position: relative;
8 years ago
margin: 3px 0;
border-radius: 4px;
background-color: #fff;
overflow: hidden;
padding: 10px 0 0 0;
}
ul.anticons-list li:hover {
8 years ago
background-color: #eaf8fe;
}
ul.anticons-list li.copied:hover {
color: rgba(255,255,255,0.2);
}
ul.anticons-list li:after {
position: absolute;
8 years ago
top: 0;
left: 0;
height: 100%;
width: 100%;
content: "Copied!";
text-align: center;
line-height: 110px;
8 years ago
color: #2db7f5;
transition: all 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
opacity: 0;
}
ul.anticons-list li.copied:after {
opacity: 1;
8 years ago
top: -10px;
}
.anticon {
font-size: 24px;
margin: 12px 0 16px;
8 years ago
transition: all .3s;
}
ul.anticons-list li:hover .anticon {
transform: scale(1.4);
}
.anticon-class {
display: block;
text-align: center;
transform: scale(0.83);
font-family: Consolas;
white-space: nowrap;
}
</style>