1 | <p align="center">
|
2 | <a href="https://uiwjs.github.io/icons">
|
3 | <img width="150" src="https://raw.githubusercontent.com/uiwjs/icons/master/assets/logo.svg?sanitize=true">
|
4 | </a>
|
5 | </p>
|
6 |
|
7 |
|
8 | @uiw/icons
|
9 | ===
|
10 |
|
11 | [](https://www.npmjs.com/package/@uiw/icons)
|
12 | [](https://www.jsdelivr.com/package/npm/@uiw/icons)
|
13 | [](https://github.com/uiwjs/icons/releases)
|
14 | [](https://github.com/uiwjs/icons)
|
15 | [](https://www.npmjs.com/package/@uiw/icons)
|
16 |
|
17 | The premium icon font for [uiwjs](https://github.com/uiwjs) Component Library. Designed [`@uiw/icons`](https://uiwjs.github.io/icons/design/) by [@liwen0526](https://github.com/liwen0526).
|
18 |
|
19 | Visit **[https://uiwjs.github.io/icons/](https://uiwjs.github.io/icons/)** and check out the search feature, which has keywords identifying common icon names and styles. For example, if you search for "arrow" we call up every icon that could possibly be used as an arrow. We've also included each icon's class name for easy copy / pasting when you're developing!
|
20 |
|
21 | They are free to use and licensed under [MIT](https://opensource.org/licenses/MIT). We intend for this icon pack to be used with [uiw](https://uiwjs.github.io), but it’s by no means limited to it. Use them wherever you see fit, personal or commercial.
|
22 |
|
23 | <p align="center">
|
24 | <a href="https://uiwjs.github.io/icons">
|
25 | <img src="https://github.com/uiwjs/icons/raw/master/assets/uiw-font.png">
|
26 | </a>
|
27 | </p>
|
28 |
|
29 | ## Installation
|
30 |
|
31 | ```bash
|
32 | npm install @uiw/icons --save
|
33 | ```
|
34 |
|
35 | ## HTML Example
|
36 |
|
37 | You can use [https://uiwjs.github.io/icons/](https://uiwjs.github.io/icons/) to easily find the icon you want to use. Once you've copied the desired icon's CSS classname, simply add the icon and icon's classname, such as `apple` to an HTML element.
|
38 |
|
39 | You need link CSS
|
40 |
|
41 | ```html
|
42 | <link rel="stylesheet" type="text/css" href="node_modules/@uiw/icons/w-icon.css">
|
43 | ```
|
44 |
|
45 | **Used in Less:**
|
46 |
|
47 | ```css
|
48 | @import "~@uiw/icons/fonts/w-icon.css";
|
49 | ```
|
50 |
|
51 | **Used in JS:**
|
52 |
|
53 | ```js
|
54 | import '@uiw/icons/fonts/w-icon.css';
|
55 | // or
|
56 | import '@uiw/icons/fonts/w-icon.less';
|
57 | ```
|
58 |
|
59 | note: It has a `w-icon-` prefix.
|
60 |
|
61 | ```html
|
62 | <i class="w-icon-apple"></i>
|
63 | ```
|
64 |
|
65 | Or use the `Unicode`, You can use [Unicode website](https://uiwjs.github.io/icons/unicode.html) to easily find the `Unicode` icon you want to use.
|
66 |
|
67 | ```html
|
68 | <style>
|
69 | .iconfont{
|
70 | font-family: "w-icon" !important;
|
71 | font-size: 16px;
|
72 | font-style: normal;
|
73 | -webkit-font-smoothing: antialiased;
|
74 | -webkit-text-stroke-width: 0.2px;
|
75 | -moz-osx-font-smoothing: grayscale;
|
76 | }
|
77 | </style>
|
78 | <span class="iconfont"></span>
|
79 | ```
|
80 |
|
81 | Or manually download and link `**@uiw/icons**` in your HTML, It can also be downloaded via [UNPKG](https://unpkg.com/@uiw/icons/):
|
82 |
|
83 | ```html
|
84 | <link rel="stylesheet" type="text/css" href="https://unpkg.com/@uiw/icons/fonts/w-icon.css">
|
85 | <span class="w-icon-adobe"></span>
|
86 | ```
|
87 |
|
88 | **In Webpack**
|
89 |
|
90 | ```js
|
91 | {
|
92 | test: /w-icon\.(eot|ttf|svg)$/,
|
93 | use: [
|
94 | {
|
95 | loader: require.resolve('url-loader'),
|
96 | options: { limit: 8192 }
|
97 | },
|
98 | {
|
99 | loader: require.resolve('file-loader'),
|
100 | options: {
|
101 | name: 'static/fonts/[name].[hash:8].[ext]',
|
102 | }
|
103 | }
|
104 | ]
|
105 | },
|
106 | ```
|
107 |
|
108 | ## React
|
109 |
|
110 | Icons are used as components. `v2.6.2+` support.
|
111 |
|
112 | ```jsx
|
113 | import { Adobe, Alipay } from '@uiw/icons';
|
114 | import { Alipay } from '@uiw/icons/Alipay';
|
115 |
|
116 | <Adobe style={{ fill: 'red' }} />
|
117 | <Alipay height="36" />
|
118 | ```
|
119 |
|
120 | **Custom Icon Component**
|
121 |
|
122 | Create an `Icon` component.
|
123 |
|
124 | ```jsx
|
125 | import React from 'react';
|
126 | import svgPaths from '@uiw/icons/fonts/w-icon.json';
|
127 |
|
128 | const renderSvgPaths = (type) => {
|
129 | const pathStrings = svgPaths[type];
|
130 | if (pathStrings == null) {
|
131 | return null
|
132 | }
|
133 | return pathStrings.map((d, i) => <path key={i} d={d} fillRule="evenodd" />)
|
134 | }
|
135 |
|
136 | export default class Icon extends React.PureComponent {
|
137 | render() {
|
138 | const { type, color } = this.props;
|
139 | if (type == null || typeof type === "boolean") {
|
140 | return null;
|
141 | }
|
142 | return (
|
143 | <svg fill={color} viewBox={`0 0 24 24`}>{this.renderSvgPaths(type)}</svg>
|
144 | );
|
145 | }
|
146 | }
|
147 | ```
|
148 |
|
149 | Use the `Icon` component:
|
150 |
|
151 | ```jsx
|
152 | const demo = () => {
|
153 | return (
|
154 | <Icon type="heart-on" />
|
155 | )
|
156 | }
|
157 | ```
|
158 |
|
159 | ## Development
|
160 |
|
161 | Run the `npm install` to install the dependencies after cloning the project and you'll be able to:
|
162 |
|
163 | To build `*.svg` `*.ttf` `*.woff` `*.eot` files
|
164 |
|
165 | ```bash
|
166 | npm run font
|
167 | ```
|
168 |
|
169 | To build site and push gh-pages branch
|
170 |
|
171 | ```bash
|
172 | npm run start
|
173 | ```
|
174 |
|
175 | ## Contributors
|
176 |
|
177 | As always, thanks to our amazing contributors!
|
178 |
|
179 | <a href="https://github.com/uiwjs/icons/graphs/contributors">
|
180 | <img src="https://uiwjs.github.io/icons/CONTRIBUTORS.svg" />
|
181 | </a>
|
182 |
|
183 | Made with [github-action-contributors](https://github.com/jaywcjlove/github-action-contributors).
|
184 |
|
185 | ## License
|
186 |
|
187 | Created By [svgtofont](https://github.com/jaywcjlove/svgtofont), Licensed under the [MIT License](https://opensource.org/licenses/MIT).
|