iconify / json
Iconify 图标集合,JSON 格式
- dev-master
- 2.2.252
- 2.2.251
- 2.2.250
- 2.2.249
- 2.2.248
- 2.2.247
- 2.2.246
- 2.2.245
- 2.2.244
- 2.2.243
- 2.2.242
- 2.2.241
- 2.2.240
- 2.2.239
- 2.2.238
- 2.2.237
- 2.2.236
- 2.2.235
- 2.2.234
- 2.2.233
- 2.2.232
- 2.2.231
- 2.2.230
- 2.2.229
- 2.2.228
- 2.2.227
- 2.2.226
- 2.2.225
- 2.2.224
- 2.2.223
- 2.2.222
- 2.2.221
- 2.2.220
- 2.2.219
- 2.2.218
- 2.2.217
- 2.2.216
- 2.2.215
- 2.2.214
- 2.2.213
- 2.2.212
- 2.2.211
- 2.2.210
- 2.2.209
- 2.2.208
- 2.2.207
- 2.2.206
- 2.2.205
- 2.2.204
- 2.2.203
- 2.2.202
- 2.2.201
- 2.2.200
- 2.2.199
- 2.2.198
- 2.2.197
- 2.2.196
- 2.2.195
- 2.2.194
- 2.2.193
- 2.2.192
- 2.2.191
- 2.2.190
- 2.2.189
- 2.2.188
- 2.2.187
- 2.2.186
- 2.2.185
- 2.2.184
- 2.2.183
- 2.2.182
- 2.2.181
- 2.2.180
- 2.2.179
- 2.2.178
- 2.2.177
- 2.2.176
- 2.2.175
- 2.2.174
- 2.2.173
- 2.2.172
- 2.2.171
- 2.2.170
- 2.2.169
- 2.2.168
- 2.2.167
- 2.2.166
- 2.2.165
- 2.2.164
- 2.2.163
- 2.2.162
- 2.2.161
- 2.2.160
- 2.2.159
- 2.2.158
- 2.2.157
- 2.2.156
- 2.2.155
- 2.2.154
- 2.2.153
- 2.2.152
- 2.2.151
- 2.2.150
- 2.2.149
- 2.2.148
- 2.2.147
- 2.2.146
- 2.2.145
- 2.2.144
- 2.2.143
- 2.2.142
- 2.2.141
- 2.2.140
- 2.2.139
- 2.2.138
- 2.2.137
- 2.2.136
- 2.2.135
- 2.2.134
- 2.2.133
- 2.2.132
- 2.2.131
- 2.2.130
- 2.2.129
- 2.2.128
- 2.2.127
- 2.2.126
- 2.2.125
- 2.2.124
- 2.2.123
- 2.2.122
- 2.2.121
- 2.2.120
- 2.2.119
- 2.2.118
- 2.2.117
- 2.2.116
- 2.2.115
- 2.2.114
- 2.2.113
- 2.2.112
- 2.2.111
- 2.2.110
- 2.2.109
- 2.2.108
- 2.2.107
- 2.2.106
- 2.2.105
- 2.2.104
- 2.2.103
- 2.2.102
- 2.2.101
- 2.2.100
- 2.2.99
- 2.2.98
- 2.2.97
- 2.2.96
- 2.2.95
- 2.2.94
- 2.2.93
- 2.2.92
- 2.2.91
- 2.2.90
- 2.2.89
- 2.2.88
- 2.2.87
- 2.2.86
- 2.2.85
- 2.2.84
- 2.2.83
- 2.2.82
- 2.2.81
- 2.2.80
- 2.2.79
- 2.2.78
- 2.2.77
- 2.2.76
- 2.2.75
- 2.2.74
- 2.2.73
- 2.2.72
- 2.2.71
- 2.2.70
- 2.2.69
- 2.2.68
- 2.2.67
- 2.2.66
- 2.2.65
- 2.2.64
- 2.2.63
- 2.2.62
- 2.2.61
- 2.2.60
- 2.2.59
- 2.2.58
- 2.2.57
- 2.2.56
- 2.2.55
- 2.2.54
- 2.2.53
- 2.2.52
- 2.2.51
- 2.2.50
- 2.2.49
- 2.2.48
- 2.2.47
- 2.2.46
- 2.2.45
- 2.2.44
- 2.2.43
- 2.2.42
- 2.2.41
- 2.2.40
- 2.2.39
- 2.2.38
- 2.2.37
- 2.2.36
- 2.2.35
- 2.2.34
- 2.2.33
- 2.2.32
- 2.2.31
- 2.2.30
- 2.2.29
- 2.2.28
- 2.2.27
- 2.2.26
- 2.2.25
- 2.2.24
- 2.2.23
- 2.2.22
- 2.2.21
- 2.2.20
- 2.2.19
- 2.2.18
- 2.2.17
- 2.2.16
- 2.2.15
- 2.2.14
- 2.2.13
- 2.2.12
- 2.2.11
- 2.2.10
- 2.2.9
- 2.2.8
- 2.2.7
- 2.2.6
- 2.2.5
- 2.2.4
- 2.2.3
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.159
- 2.1.158
- 2.1.157
- 2.1.156
- 2.1.155
- 2.1.154
- 2.1.153
- 2.1.152
- 2.1.151
- 2.1.150
- 2.1.149
- 2.1.148
- 2.1.147
- 2.1.146
- 2.1.145
- 2.1.144
- 2.1.143
- 2.1.142
- 2.1.141
- 2.1.140
- 2.1.139
- 2.1.138
- 2.1.137
- 2.1.136
- 2.1.135
- 2.1.134
- 2.1.133
- 2.1.132
- 2.1.131
- 2.1.130
- 2.1.129
- 2.1.128
- 2.1.127
- 2.1.126
- 2.1.125
- 2.1.124
- 2.1.123
- 2.1.122
- 2.1.121
- 2.1.120
- 2.1.119
- 2.1.118
- 2.1.117
- 2.1.116
- 2.1.115
- 2.1.114
- 2.1.113
- 2.1.112
- 2.1.111
- 2.1.110
- 2.1.109
- 2.1.108
- 2.1.107
- 2.1.106
- 2.1.105
- 2.1.104
- 2.1.103
- 2.1.102
- 2.1.101
- 2.1.100
- 2.1.99
- 2.1.98
- 2.1.97
- 2.1.96
- 2.1.95
- 2.1.94
- 2.1.93
- 2.1.92
- 2.1.91
- 2.1.90
- 2.1.89
- 2.1.88
- 2.1.87
- 2.1.86
- 2.1.85
- 2.1.84
- 2.1.83
- 2.1.82
- 2.1.81
- 2.1.80
- 2.1.79
- 2.1.78
- 2.1.77
- 2.1.76
- 2.1.75
- 2.1.74
- 2.1.73
- 2.1.72
- 2.1.71
- 2.1.70
- 2.1.69
- 2.1.68
- 2.1.67
- 2.1.66
- 2.1.65
- 2.1.64
- 2.1.63
- 2.1.62
- 2.1.61
- 2.1.60
- 2.1.59
- 2.1.58
- 2.1.57
- 2.1.56
- 2.1.55
- 2.1.54
- 2.1.53
- 2.1.52
- 2.1.51
- 2.1.50
- 2.1.49
- 2.1.48
- 2.1.47
- 2.1.46
- 2.1.45
- 2.1.44
- 2.1.43
- 2.1.42
- 2.1.41
- 2.1.40
- 2.1.39
- 2.1.38
- 2.1.37
- 2.1.36
- 2.1.35
- 2.1.34
- 2.1.33
- 2.1.32
- 2.1.31
- 2.1.30
- 2.1.29
- 2.1.28
- 2.1.27
- 2.1.26
- 2.1.25
- 2.1.24
- 2.1.23
- 2.1.22
- 2.1.21
- 2.1.20
- 2.1.19
- 2.1.18
- 2.1.17
- 2.1.16
- 2.1.15
- 2.1.14
- 2.1.13
- 2.1.12
- 2.1.11
- 2.1.10
- 2.1.9
- 2.1.8
- 2.1.7
- 2.1.6
- 2.1.5
- 2.1.4
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.36
- 2.0.35
- 2.0.34
- 2.0.33
- 2.0.32
- 2.0.31
- 2.0.30
- 2.0.29
- 2.0.28
- 2.0.27
- 2.0.26
- 2.0.25
- 2.0.24
- 2.0.23
- 2.0.22
- 2.0.21
- 2.0.20
- 2.0.19
- 2.0.18
- 2.0.17
- 2.0.16
- 2.0.15
- 2.0.14
- 2.0.13
- 2.0.12
- 2.0.11
- 2.0.10
- 2.0.9
- 2.0.8
- 2.0.7
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- v1.x-dev
- 1.1.461
- 1.1.460
- 1.1.459
- 1.1.458
- 1.1.457
- 1.1.456
- 1.1.455
- 1.1.454
- 1.1.453
- 1.1.452
- 1.1.451
- 1.1.450
- 1.1.449
- 1.1.448
- 1.1.447
- 1.1.446
- 1.1.445
- 1.1.444
- 1.1.443
- 1.1.442
- 1.1.441
- 1.1.440
- 1.1.439
- 1.1.438
- 1.1.437
- 1.1.436
- 1.1.435
- 1.1.434
- 1.1.433
- 1.1.432
- 1.1.431
- 1.1.430
- 1.1.429
- 1.1.428
- 1.1.427
- 1.1.426
- 1.1.425
- 1.1.424
- 1.1.423
- 1.1.422
- 1.1.421
- 1.1.420
- 1.1.419
- 1.1.418
- 1.1.417
- 1.1.416
- 1.1.415
- 1.1.414
- 1.1.413
- 1.1.412
- 1.1.411
- 1.1.410
- 1.1.409
- 1.1.408
- 1.1.407
- 1.1.406
- 1.1.405
- 1.1.404
- 1.1.403
- 1.1.402
- 1.1.401
- 1.1.400
- 1.1.399
- 1.1.398
- 1.1.397
- 1.1.396
- 1.1.395
- 1.1.394
- 1.1.393
- 1.1.392
- 1.1.391
- 1.1.390
- 1.1.389
- 1.1.388
- 1.1.387
- 1.1.386
- 1.1.385
- 1.1.384
- 1.1.383
- 1.1.382
- 1.1.381
- 1.1.380
- 1.1.379
- 1.1.378
- 1.1.377
- 1.1.376
- 1.1.375
- 1.1.374
- 1.1.373
- 1.1.372
- 1.1.371
- 1.1.370
- 1.1.369
- 1.1.368
- 1.1.367
- 1.1.366
- 1.1.365
- 1.1.364
- 1.1.363
- 1.1.362
- 1.1.361
- 1.1.360
- 1.1.359
- 1.1.358
- 1.1.357
- 1.1.356
- 1.1.355
- 1.1.354
- 1.1.353
- 1.1.352
- 1.1.351
- 1.1.350
- 1.1.349
- 1.1.348
- 1.1.347
- 1.1.346
- 1.1.345
- 1.1.344
- 1.1.343
- 1.1.342
- 1.1.341
- 1.1.340
- 1.1.339
- 1.1.338
- 1.1.337
- 1.1.336
- 1.1.335
- 1.1.334
- 1.1.333
- 1.1.332
- 1.1.331
- 1.1.330
- 1.1.329
- 1.1.328
- 1.1.327
- 1.1.326
- 1.1.325
- 1.1.324
- 1.1.323
- 1.1.322
- 1.1.321
- 1.1.320
- 1.1.319
- 1.1.318
- 1.1.317
- 1.1.316
- 1.1.315
- 1.1.314
- 1.1.313
- 1.1.312
- 1.1.311
- 1.1.310
- 1.1.309
- 1.1.308
- 1.1.307
- 1.1.306
- 1.1.305
- 1.1.304
- 1.1.303
- 1.1.302
- 1.1.301
- 1.1.300
- 1.1.299
- 1.1.298
- 1.1.297
- 1.1.296
- 1.1.295
- 1.1.294
- 1.1.293
- 1.1.292
- 1.1.291
- 1.1.290
- 1.1.289
- 1.1.288
- 1.1.287
- 1.1.286
- 1.1.285
- 1.1.284
- 1.1.283
- 1.1.282
- 1.1.281
- 1.1.280
- 1.1.279
- 1.1.278
- 1.1.277
- 1.1.276
- 1.1.275
- 1.1.274
- 1.1.273
- 1.1.272
- 1.1.271
- 1.1.270
- 1.1.269
- 1.1.268
- 1.1.267
- 1.1.266
- 1.1.265
- 1.1.264
- 1.1.263
- 1.1.262
- 1.1.261
- 1.1.260
- 1.1.259
- 1.1.258
- 1.1.257
- 1.1.256
- 1.1.255
- 1.1.254
- 1.1.253
- 1.1.252
- 1.1.251
- 1.1.250
- 1.1.249
- 1.1.248
- 1.1.247
- 1.1.246
- 1.1.245
- 1.1.244
- 1.1.243
- 1.1.242
- 1.1.241
- 1.1.240
- 1.1.239
- 1.1.238
- 1.1.237
- 1.1.236
- 1.1.235
- 1.1.234
- 1.1.233
- 1.1.232
- 1.1.231
- 1.1.230
- 1.1.229
- 1.1.228
- 1.1.227
- 1.1.226
- 1.1.225
- 1.1.224
- 1.1.223
- 1.1.222
- 1.1.221
- 1.1.220
- 1.1.219
- 1.1.218
- 1.1.217
- 1.1.216
- 1.1.215
- 1.1.214
- 1.1.213
- 1.1.212
- 1.1.211
- 1.1.210
- 1.1.209
- 1.1.208
- 1.1.207
- 1.1.206
- 1.1.205
- 1.1.204
- 1.1.203
- 1.1.202
- 1.1.201
- 1.1.200
- 1.1.199
- 1.1.198
- 1.1.197
- 1.1.196
- 1.1.195
- 1.1.194
- 1.1.193
- 1.1.192
- 1.1.191
- 1.1.190
- 1.1.189
- 1.1.188
- 1.1.187
- 1.1.186
- 1.1.185
- 1.1.184
- 1.1.183
- 1.1.182
- 1.1.181
- 1.1.180
- 1.1.179
- 1.1.178
- 1.1.177
- 1.1.176
- 1.1.175
- 1.1.174
- 1.1.173
- 1.1.172
- 1.1.171
- 1.1.170
- 1.1.169
- 1.1.168
- 1.1.167
- 1.1.166
- 1.1.165
- 1.1.164
- 1.1.163
- 1.1.162
- 1.1.161
- 1.1.160
- 1.1.159
- 1.1.158
- 1.1.157
- 1.1.156
- 1.1.155
- 1.1.154
- 1.1.153
- 1.1.152
- 1.1.151
- 1.1.150
- 1.1.149
- 1.1.148
- 1.1.147
- 1.1.146
- 1.1.145
- 1.1.144
- 1.1.143
- 1.1.142
- 1.1.141
- 1.1.140
- 1.1.139
- 1.1.138
- 1.1.137
- 1.1.136
- 1.1.135
- 1.1.134
- 1.1.133
- 1.1.132
- 1.1.131
- 1.1.130
- 1.1.129
- 1.1.128
- 1.1.127
- 1.1.126
- 1.1.125
- 1.1.124
- 1.1.123
- 1.1.122
- 1.1.121
- 1.1.120
- 1.1.119
- 1.1.118
- 1.1.117
- 1.1.116
- 1.1.115
- 1.1.114
- 1.1.113
- 1.1.112
- 1.1.111
- 1.1.110
- 1.1.109
- 1.1.108
- 1.1.107
- 1.1.106
- 1.1.105
- 1.1.104
- 1.1.103
- 1.1.102
- 1.1.101
- 1.1.100
- 1.1.99
- 1.1.98
- 1.1.97
- 1.1.96
- 1.1.95
- 1.1.94
- 1.1.93
- 1.1.92
- 1.1.91
- 1.1.90
- 1.1.89
- 1.1.88
- 1.1.87
- 1.1.86
- 1.1.85
- 1.1.84
- 1.1.83
- 1.1.82
- 1.1.81
- 1.1.80
- 1.1.79
- 1.1.78
- 1.1.77
- 1.1.76
- 1.1.75
- 1.1.74
- 1.1.73
- 1.1.72
- 1.1.71
- 1.1.70
- 1.1.69
- 1.1.68
- 1.1.67
- 1.1.66
- 1.1.65
- 1.1.64
- 1.1.63
- 1.1.62
- 1.1.61
- 1.1.60
- 1.1.59
- 1.1.58
- 1.1.57
- 1.1.56
- 1.1.55
- 1.1.54
- 1.1.53
- 1.1.52
- 1.1.51
- 1.1.50
- 1.1.49
- 1.1.48
- 1.1.47
- 1.1.46
- 1.1.45
- 1.1.44
- 1.1.43
- 1.1.42
- 1.1.41
- 1.1.40
- 1.1.39
- 1.1.37
- 1.1.36
- 1.1.35
- 1.1.34
- 1.1.33
- 1.1.32
- 1.1.31
- 1.1.30
- 1.1.29
- 1.1.28
- 1.1.27
- 1.1.26
- 1.1.25
- 1.1.24
- 1.1.23
- 1.1.22
- 1.1.21
- 1.1.20
- 1.1.19
- 1.1.18
- 1.1.17
- 1.1.16
- 1.1.15
- 1.1.14
- 1.1.13
- 1.1.12
- 1.1.11
- 1.1.10
- 1.1.9
- 1.1.8
- 1.1.7
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.0.155
- 1.0.154
- 1.0.153
- 1.0.152
- 1.0.151
- 1.0.150
- 1.0.149
- 1.0.148
- 1.0.147
- 1.0.146
- 1.0.145
- 1.0.144
- 1.0.143
- 1.0.142
- 1.0.141
- 1.0.140
- 1.0.139
- 1.0.138
- 1.0.137
- 1.0.136
- 1.0.135
- 1.0.134
- 1.0.133
- 1.0.132
- 1.0.131
- 1.0.130
- 1.0.129
- 1.0.128
- 1.0.127
- 1.0.126
- 1.0.125
- 1.0.124
- 1.0.123
- 1.0.122
- 1.0.121
- 1.0.120
- 1.0.119
- 1.0.118
- 1.0.117
- 1.0.116
- 1.0.115
- 1.0.114
- 1.0.113
- 1.0.112
- 1.0.111
- 1.0.110
- 1.0.109
- 1.0.108
- 1.0.107
- 1.0.106
- 1.0.105
- 1.0.104
- 1.0.103
- 1.0.102
- 1.0.101
- 1.0.100
- 1.0.99
- 1.0.98
- 1.0.97
- 1.0.96
- 1.0.95
- 1.0.94
- 1.0.93
- 1.0.92
- 1.0.91
- 1.0.90
- 1.0.89
- 1.0.88
- 1.0.87
- 1.0.86
- 1.0.85
- 1.0.84
- 1.0.83
- 1.0.82
- 1.0.81
- 1.0.80
- 1.0.79
- 1.0.78
- 1.0.77
- 1.0.76
- 1.0.75
- 1.0.74
- 1.0.73
- 1.0.72
- 1.0.71
- 1.0.70
- 1.0.69
- 1.0.68
- 1.0.67
- 1.0.66
- 1.0.65
- 1.0.64
- 1.0.63
- 1.0.62
- 1.0.61
- 1.0.60
- 1.0.59
- 1.0.58
- 1.0.57
- 1.0.56
- 1.0.55
- 1.0.54
- 1.0.53
- 1.0.52
- 1.0.51
- 1.0.50
- 1.0.49
- 1.0.48
- 1.0.47
- 1.0.46
- 1.0.45
- 1.0.44
- 1.0.43
- 1.0.42
- 1.0.41
- 1.0.40
- 1.0.39
- 1.0.38
- 1.0.37
- 1.0.36
- 1.0.35
- 1.0.34
- 1.0.33
- 1.0.32
- 1.0.31
- 1.0.30
- 1.0.29
- 1.0.28
- 1.0.27
- 1.0.26
- 1.0.25
- 1.0.24
- 1.0.23
- 1.0.22
- 1.0.21
- 1.0.20
- 1.0.19
- 1.0.18
- 1.0.17
- 1.0.16
- 1.0.15
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
This package is auto-updated.
Last update: 2024-09-23 05:04:54 UTC
README
这是一个开源矢量图标的巨大集合,所有图标都已验证、整理并转换为易于使用的格式。
尽管所有图标集都是开源的,但某些图标集需要署名。
请参阅collections.md以获取图标集及其许可证的列表。
验证和整理
所有图标都经过Iconify Tools处理,以进行整理。
图标解析过程包括
- 非常严格的验证和整理。图标不包含脚本、监听器、字体、位图图像、外部资源和未知元素。
- 单色图标的颜色已被替换为
currentColor
,这使得通过更改文本颜色来更改图标颜色变得容易。 - 图标内容已优化以减小其大小。
维护
此存储库每周自动更新几次,因此它始终包含所有图标集的最新图标。
格式
图标集存储在IconifyJSON
格式中。TypeScript 定义在@iconify/types
包中可用。文档可在Iconify 文档网站上找到。
要使用图标集,请使用Iconify Utils。Utils 包在任何 JavaScript 环境中工作:Node.js、Deno、浏览器、隔离的 JavaScript 环境。
使用方法
这些图标可以与许多工具、插件和组件一起使用。它们也可以导出为单独的 SVG 文件。
请参阅Iconify 文档获取更多详细信息。
如何获取此存储库
以下说明适用于 Node.js 和 PHP 项目。
Node.js
运行此命令将图标添加到您的项目
npm install --save @iconify/json
图标将在 node_modules/@iconify/json 中可用
如果您使用 CommonJS 语法,则使用此方法解析任何 json 文件的文件名
import { locate } from '@iconify/json'; // returns location of mdi-light.json const mdiLightFilename = locate('mdi-light');
PHP
安装并初始化 Composer 项目。请参阅https://getcomposer.org.cn上的文档
然后打开 composer.json 并添加以下代码
"require": { "php": ">=5.6", "iconify/json": "*" }
然后运行
composer install
图标将在 vendor/iconify/json/ 中可用
如果您不使用 Composer,请克隆 GitHub 存储库并添加必要的自动加载代码。
要解析任何 json 文件的文件名,请使用此方法
// Returns location of mdi-light.json $mdiLightLocation = \Iconify\IconsJSON\Finder::locate('mdi-light');
数据格式
Iconify 使用的图标在 json 目录中,以 Iconify JSON 格式。
为什么是 JSON 而不是 SVG?有几个原因
- 易于批量存储图像。
- 仅包含图标的内容,不包含
<svg>
元素,这使得在不进行复杂解析的情况下操作内容变得容易。这也使得创建组件(例如 React 图标组件)变得容易,允许使用框架本地的 SVG 元素。 - 数据可以包含附加内容:图标的别名、图标集信息、分类/标签/主题。
为什么不是 XML?
- JSON 没有额外的工具就更容易解析。所有语言都支持它。
json 文件的格式非常简单
{ "prefix": "mdi-light", "icons": { "icon-name": { "body": "<g />", "width": 24, "height": 24 } }, "aliases": { "icon-alias": { "parent": "icon-name" } } }
"icons" 对象包含所有图标的列表。
每个图标具有以下属性
- body: 图标主体。
- left, top: viewBox 的左和顶坐标,默认为 0。
- width, height:viewBox的尺寸,默认为16。
- rotate:旋转。默认值 = 0。值:0 = 0度,1 = 90度,2 = 180度,3 = 270度。
- hFlip:水平翻转。布尔值,默认 = false。
- vFlip:垂直翻转。布尔值,默认 = false。
- hidden:如果设置为true,则图标被隐藏。这意味着图标由于某些原因从集合中移除,但保留在JSON文件中以防止依赖旧图标的程序崩溃。
可选的"aliases"对象包含图标的别名列表。格式与"icons"对象类似,但没有"body"属性,并添加了指向父图标的"parent"属性。转换属性(rotate, hFlip, vFlip)与父图标的属性合并。任何其他属性都将覆盖父图标的属性。
当多个图标具有相同的值时,将其移动到根对象以减少重复。
{ "prefix": "mdi-light", "icons": { "icon1": { "body": "<g />" }, "icon2": { "body": "<g />" }, "icon-20": { "body": "<g />", "width": 20, "height": 20 } }, "width": 24, "height": 24 }
在上面的示例中,"icon1"和"icon2"的大小为24x24,"icon-20"的大小为20x20。
有关更多信息,请参阅开发者文档
提取单个SVG图标
您可以使用Iconify Utils进行简单的导出过程,或使用Iconify Tools获取更多选项。
使用Iconify Utils(TypeScript)的示例
import { promises as fs } from 'fs'; // Function to locate JSON file import { locate } from '@iconify/json'; // Various functions from Iconify Utils import { parseIconSet } from '@iconify/utils/lib/icon-set/parse'; import { iconToSVG } from '@iconify/utils/lib/svg/build'; import { defaults } from '@iconify/utils/lib/customisations'; (async () => { // Locate icons const filename = locate('mdi'); // Load icon set const icons = JSON.parse(await fs.readFile(filename, 'utf8')); // Parse all icons const exportedSVG: Record<string, string> = Object.create(null); parseIconSet(icons, (iconName, iconData) => { if (!iconData) { // Invalid icon console.error(`Error parsing icon ${iconName}`); return; } // Render icon const renderData = iconToSVG(iconData, { ...defaults, height: 'auto', }); // Generate attributes for SVG element const svgAttributes: Record<string, string> = { 'xmlns': 'http://www.w3.org/2000/svg', 'xmlns:xlink': 'http://www.w3.org/1999/xlink', ...renderData.attributes, }; const svgAttributesStr = Object.keys(svgAttributes) .map( (attr) => // No need to check attributes for special characters, such as quotes, // they cannot contain anything that needs escaping. `${attr}="${svgAttributes[attr as keyof typeof svgAttributes]}"` ) .join(' '); // Generate SVG const svg = `<svg ${svgAttributesStr}>${renderData.body}</svg>`; exportedSVG[iconName] = svg; }); // Output directory const outputDir = 'mdi-export'; try { await fs.mkdir(outputDir, { recursive: true, }); } catch (err) { // } // Save all files const filenames = Object.keys(exportedSVG); for (let i = 0; i < filenames.length; i++) { const filename = filenames[i]; const svg = exportedSVG[filename]; await fs.writeFile(outputDir + '/' + filename + '.svg', svg, 'utf8'); } })();
使用Iconify Tools的相同示例
import { readFile, writeFile, mkdir } from 'fs'; import { SVG } from '@iconify/tools'; const outputDir = 'mdi-export'; // Create target directory try { await mkdir(outputDir, { recursive: true, }); } catch (err) { // } // Locate icons const filename = locate('mdi'); // Load icon set const data = JSON.parse(await fs.readFile(filename, 'utf8')); // Create IconSet instance const iconSet = new IconSet(data); // Export all icons await iconSet.forEach(async (name) => { const svg = iconSet.toString(name); if (!svg) { return; } // Save to file await writeFile(`${outputDir}/${name}.svg`, svg, 'utf8'); console.log(`Saved ${outputDir}/${name}.svg (${svg.length} bytes)`); });
有关更多导出选项,请参阅Iconify Tools文档
许可证
这是由不同作者创建的图标集合。
请参阅collections.md以获取图标集及其许可证的列表。