naive-icons 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/LICENSE +21 -0
  3. package/README.en.md +278 -0
  4. package/README.md +278 -0
  5. package/assets/logo.svg +11 -0
  6. package/dist/index.d.mts +240 -0
  7. package/dist/index.d.ts +240 -0
  8. package/dist/index.js +876 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/index.mjs +772 -0
  11. package/dist/index.mjs.map +1 -0
  12. package/package.json +76 -0
  13. package/svg/airplane.svg +4 -0
  14. package/svg/anchor.svg +8 -0
  15. package/svg/apple.svg +7 -0
  16. package/svg/balloon.svg +9 -0
  17. package/svg/bear.svg +14 -0
  18. package/svg/bee.svg +12 -0
  19. package/svg/bell.svg +7 -0
  20. package/svg/bicycle.svg +12 -0
  21. package/svg/bird.svg +7 -0
  22. package/svg/book.svg +7 -0
  23. package/svg/bookmark.svg +4 -0
  24. package/svg/bulb.svg +7 -0
  25. package/svg/butterfly.svg +12 -0
  26. package/svg/cactus.svg +13 -0
  27. package/svg/cake.svg +8 -0
  28. package/svg/calendar.svg +10 -0
  29. package/svg/camera.svg +7 -0
  30. package/svg/candle.svg +8 -0
  31. package/svg/car.svg +6 -0
  32. package/svg/cart.svg +5 -0
  33. package/svg/cat.svg +11 -0
  34. package/svg/chat.svg +6 -0
  35. package/svg/check.svg +4 -0
  36. package/svg/cherry.svg +9 -0
  37. package/svg/clock.svg +6 -0
  38. package/svg/close.svg +5 -0
  39. package/svg/cloud.svg +5 -0
  40. package/svg/code.svg +5 -0
  41. package/svg/coffee.svg +7 -0
  42. package/svg/compass.svg +5 -0
  43. package/svg/credit-card.svg +6 -0
  44. package/svg/dog.svg +10 -0
  45. package/svg/donut.svg +10 -0
  46. package/svg/download.svg +5 -0
  47. package/svg/edit.svg +5 -0
  48. package/svg/eye.svg +6 -0
  49. package/svg/file.svg +6 -0
  50. package/svg/fish.svg +6 -0
  51. package/svg/flag.svg +5 -0
  52. package/svg/flame.svg +4 -0
  53. package/svg/flower.svg +8 -0
  54. package/svg/folder.svg +4 -0
  55. package/svg/fox.svg +11 -0
  56. package/svg/frog.svg +12 -0
  57. package/svg/gift.svg +7 -0
  58. package/svg/globe.svg +9 -0
  59. package/svg/headphones.svg +5 -0
  60. package/svg/heart.svg +5 -0
  61. package/svg/home.svg +7 -0
  62. package/svg/icecream.svg +9 -0
  63. package/svg/image.svg +6 -0
  64. package/svg/key.svg +7 -0
  65. package/svg/ladybug.svg +11 -0
  66. package/svg/lamp.svg +8 -0
  67. package/svg/leaf.svg +4 -0
  68. package/svg/lemon.svg +8 -0
  69. package/svg/location.svg +4 -0
  70. package/svg/lock.svg +6 -0
  71. package/svg/magnet.svg +5 -0
  72. package/svg/mail.svg +6 -0
  73. package/svg/map.svg +7 -0
  74. package/svg/mic.svg +6 -0
  75. package/svg/moon.svg +5 -0
  76. package/svg/mushroom.svg +11 -0
  77. package/svg/music.svg +5 -0
  78. package/svg/owl.svg +14 -0
  79. package/svg/paintbrush.svg +6 -0
  80. package/svg/pencil.svg +7 -0
  81. package/svg/penguin.svg +13 -0
  82. package/svg/phone.svg +3 -0
  83. package/svg/play.svg +4 -0
  84. package/svg/plus.svg +5 -0
  85. package/svg/rabbit.svg +16 -0
  86. package/svg/rainbow.svg +9 -0
  87. package/svg/refresh.svg +4 -0
  88. package/svg/rocket.svg +7 -0
  89. package/svg/sailboat.svg +8 -0
  90. package/svg/save.svg +7 -0
  91. package/svg/search.svg +5 -0
  92. package/svg/settings.svg +4 -0
  93. package/svg/share.svg +7 -0
  94. package/svg/shopping-bag.svg +7 -0
  95. package/svg/smile.svg +8 -0
  96. package/svg/snail.svg +12 -0
  97. package/svg/snowflake.svg +12 -0
  98. package/svg/star.svg +5 -0
  99. package/svg/strawberry.svg +10 -0
  100. package/svg/sun.svg +11 -0
  101. package/svg/tag.svg +4 -0
  102. package/svg/thermometer.svg +5 -0
  103. package/svg/thumbs-up.svg +4 -0
  104. package/svg/train.svg +14 -0
  105. package/svg/trash.svg +7 -0
  106. package/svg/tree.svg +6 -0
  107. package/svg/trophy.svg +8 -0
  108. package/svg/umbrella.svg +8 -0
  109. package/svg/upload.svg +5 -0
  110. package/svg/user.svg +7 -0
  111. package/svg/video.svg +5 -0
  112. package/svg/watermelon.svg +10 -0
  113. package/svg/wifi.svg +5 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,38 @@
1
+ # 更新日志
2
+
3
+ 本文件记录 Naive Icons 的每个版本变更。版本号遵循语义化版本规范(SemVer)。
4
+
5
+ ## Unreleased
6
+
7
+ 官方文档站点重构。图标与组件产物无任何变更。
8
+
9
+ 改进
10
+
11
+ - 官网三层(HTML / CSS / JS)完全重写:语义化标签、统一的设计令牌体系(间距 4px 基数、圆角与阴影尺度)、清除模板导出的冗余属性
12
+ - 信息架构收敛:原先并列的 4 个代码面板合并为「安装 / React / SVG / TypeScript」标签页,调色板与设计原则合并为「设计规范」一节
13
+ - 视觉基调改为温暖手绘:纸张颗粒纹理、暖调深色模式、手绘分隔线,浅色与深色主题均可手动切换并记忆
14
+ - 引入 LXGW 悠哉字体(OFL,自托管子集化,仅 715 个字符 ≈ 170KB ×2 个字重)作为网站字体;图标库本体仍无任何字体/资源依赖
15
+ - 图标浏览器工具栏在宽屏下吸顶,新增分类结果计数、搜索清空、描边快捷色板与自定义取色器
16
+ - 预览切换深色底时,若描边仍为默认墨黑会自动换成奶油色,避免图标不可见;用户显式选择的颜色不会被改写
17
+ - 详情弹窗支持键盘方向键连续切换图标,打开时背景内容设为 inert
18
+ - 无障碍补强:skip link、aria-live 结果计数、标签页方向键切换、焦点归还
19
+
20
+ ## 1.0.0
21
+
22
+ 首个正式版本发布。
23
+
24
+ 新增
25
+
26
+ - 101 个手绘 naive folk art 风格 SVG 图标,覆盖界面基础、操作、文件与媒体、导航方位、通信、自然天气、动物、食物饮品、日常物品、交通工具、表情共 11 个分类
27
+ - 每个图标同时提供 SVG 源文件与 React TSX 组件
28
+ - 完整 TypeScript 类型定义:IconProps、IconName、IconCategory、PaletteColor、NAIVE_PALETTE
29
+ - 统一规格:48x48 viewBox、3.5 描边宽度、round 线帽与线角
30
+ - 9 色复古调色板,可作为设计令牌直接引用
31
+ - 官方文档站点,支持搜索、分类筛选、尺寸与描边颜色实时调整、一键复制与下载
32
+ - MIT 协议,全部图标为原创作品
33
+
34
+ 改进
35
+
36
+ - 组件默认使用 currentColor,可自动继承父级文字颜色
37
+ - 支持 size、color、strokeWidth、fill、title 五个语义属性,同时继承全部原生 SVG 属性
38
+ - 单个图标体积控制在 400 至 700 字节,无运行时依赖
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Naive Icons
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.en.md ADDED
@@ -0,0 +1,278 @@
1
+ <p align="right">
2
+ <a href="./README.md">中文</a> | <a href="./README.en.md">English</a>
3
+ </p>
4
+
5
+ <p align="center">
6
+ <img src="assets/logo.svg" alt="Naive Icons" width="132" height="132">
7
+ </p>
8
+
9
+ <h1 align="center">Naive Icons</h1>
10
+
11
+ <p align="center">Hand-drawn "naive folk art" style SVG icon library, built for React and TypeScript</p>
12
+
13
+ Naive Icons is a hand-drawn SVG icon library with a naive folk art style, built for React and TypeScript. All 101 icons are AI-generated original works.
14
+
15
+ Each icon is drawn on a 48x48 grid with a 3.5 stroke, rounded line caps, and a unified retro palette — keeping the charming clumsiness and warmth of hand-drawn illustration. Some icons even feature a pair of dot eyes and a little smile, adding a touch of humanity to your interface.
16
+
17
+ - Icon count: 101
18
+ - Per-icon size: roughly 400–700 bytes
19
+ - Dependencies: zero runtime dependencies, React as a peer dependency only
20
+ - License: MIT
21
+
22
+ ## Contents
23
+
24
+ - [Features](#features)
25
+ - [Installation](#installation)
26
+ - [Quick Start](#quick-start)
27
+ - [Component Props](#component-props)
28
+ - [Using the SVG Directly](#using-the-svg-directly)
29
+ - [Palette](#palette)
30
+ - [Icon List](#icon-list)
31
+ - [Design Principles](#design-principles)
32
+ - [Directory Structure](#directory-structure)
33
+ - [Local Development](#local-development)
34
+ - [Browser Support](#browser-support)
35
+ - [License](#license)
36
+
37
+ ## Features
38
+
39
+ - 101 original hand-drawn SVG icons spanning 11 categories: interface, actions, media, navigation, animals, food, and more
40
+ - Unified spec: 48x48 viewBox, 3.5 stroke width, round line caps and joins
41
+ - Unified palette: 9 retro colors, usable directly as design tokens
42
+ - Some icons feature dot eyes and a little smile for a highly recognizable style
43
+ - Every icon ships as both an SVG source file and a React TSX component
44
+ - Full TypeScript types: IconProps, IconName, IconCategory, NAIVE_PALETTE
45
+ - Transparent background, no gradients, no external font dependency
46
+ - Supports currentColor, so icons automatically follow the surrounding text color
47
+
48
+ ## Installation
49
+
50
+ ```bash
51
+ npm install naive-icons
52
+ ```
53
+
54
+ ```bash
55
+ yarn add naive-icons
56
+ ```
57
+
58
+ ```bash
59
+ pnpm add naive-icons
60
+ ```
61
+
62
+ Naive Icons only depends on React and supports React 16.8 and above (including React 18 and 19).
63
+
64
+ ## Quick Start
65
+
66
+ ```tsx
67
+ import { HomeIcon, HeartIcon, PenguinIcon } from 'naive-icons';
68
+
69
+ export function Example() {
70
+ return (
71
+ <nav>
72
+ <HomeIcon size={24} />
73
+ <HeartIcon size={24} color="#E76F51" />
74
+ <PenguinIcon size={48} strokeWidth={4} />
75
+ </nav>
76
+ );
77
+ }
78
+ ```
79
+
80
+ Import per icon to further reduce bundle size:
81
+
82
+ ```tsx
83
+ import HomeIcon from 'naive-icons/src/HomeIcon';
84
+ ```
85
+
86
+ Use with currentColor so icons automatically inherit the parent text color:
87
+
88
+ ```tsx
89
+ <span style={{ color: '#264653' }}>
90
+ <HomeIcon size={20} />
91
+ Home
92
+ </span>
93
+ ```
94
+
95
+ Add an accessibility title:
96
+
97
+ ```tsx
98
+ <HomeIcon size={24} title="Back to home" />
99
+ ```
100
+
101
+ ## Component Props
102
+
103
+ Every Naive Icon component extends the native `SVGProps<SVGSVGElement>`, so you can pass any SVG attribute directly, such as `className`, `onClick`, or `style`.
104
+
105
+ | Prop | Type | Default | Description |
106
+ | --- | --- | --- | --- |
107
+ | size | number \| string | 24 | Icon size, equal width and height. Overrides width and height when set |
108
+ | color | string | currentColor | Stroke color |
109
+ | strokeWidth | number \| string | 3.5 | Stroke width, scaled to the 48x48 canvas |
110
+ | fill | string | none | Fill color |
111
+ | title | string | — | Accessibility title, rendered as an SVG title node |
112
+ | width / height | number \| string | follows size | Set width or height individually |
113
+
114
+ ```typescript
115
+ import type { IconProps } from 'naive-icons';
116
+
117
+ interface IconProps extends SVGProps<SVGSVGElement> {
118
+ size?: number | string;
119
+ color?: string;
120
+ strokeWidth?: number | string;
121
+ fill?: string;
122
+ title?: string;
123
+ }
124
+ ```
125
+
126
+ ## Using the SVG Directly
127
+
128
+ If your project isn't React, you can use the source files in the `svg/` directory. Every SVG is self-contained with no external references.
129
+
130
+ ```html
131
+ <img src="naive-icons/svg/home.svg" width="24" height="24" alt="Home" />
132
+ ```
133
+
134
+ To follow the surrounding text color when inlining, replace `stroke="#2A2A2A"` with `stroke="currentColor"`:
135
+
136
+ ```html
137
+ <svg viewBox="0 0 48 48" width="24" height="24" fill="none"
138
+ stroke="currentColor" stroke-width="3.5"
139
+ stroke-linecap="round" stroke-linejoin="round">
140
+ <!-- Copy the path content from svg/home.svg -->
141
+ </svg>
142
+ ```
143
+
144
+ You can also build an SVG sprite or icon font — the source files are simple enough to work with.
145
+
146
+ ## Palette
147
+
148
+ ```typescript
149
+ import { NAIVE_PALETTE } from 'naive-icons';
150
+ ```
151
+
152
+ | Name | Value | Usage |
153
+ | --- | --- | --- |
154
+ | ink | #2A2A2A | Primary stroke |
155
+ | navy | #264653 | Dark main body |
156
+ | orange | #E76F51 | Accent |
157
+ | yellow | #E9C46A | Warm fill |
158
+ | pink | #F4A6A4 | Soft fill |
159
+ | green | #588157 | Natural elements |
160
+ | teal | #2A9D8F | Secondary |
161
+ | brown | #8B5E3C | Wood and earth |
162
+ | cream | #FAEDCD | Light background |
163
+
164
+ ## Icon List
165
+
166
+ **Interface Basics** (13)
167
+ home, user, settings, search, heart, star, bell, calendar, clock, eye, bulb, tag, bookmark
168
+
169
+ **Actions** (11)
170
+ edit, trash, download, upload, save, plus, close, check, refresh, share, play
171
+
172
+ **Files & Media** (9)
173
+ file, folder, image, camera, video, mic, music, code, book
174
+
175
+ **Navigation & Direction** (6)
176
+ location, compass, map, flag, anchor, magnet
177
+
178
+ **Communication** (4)
179
+ mail, chat, phone, wifi
180
+
181
+ **Nature & Weather** (12)
182
+ sun, moon, cloud, umbrella, tree, flower, leaf, rainbow, mushroom, cactus, snowflake, flame
183
+
184
+ **Animals** (14)
185
+ cat, dog, bird, fish, penguin, rabbit, bear, fox, owl, frog, bee, butterfly, snail, ladybug
186
+
187
+ **Food & Drink** (9)
188
+ apple, strawberry, watermelon, cherry, lemon, cake, icecream, donut, coffee
189
+
190
+ **Everyday Objects** (13)
191
+ balloon, lamp, candle, pencil, paintbrush, globe, trophy, shopping-bag, credit-card, gift, thermometer, lock, key
192
+
193
+ **Transport** (7)
194
+ car, airplane, rocket, cart, bicycle, sailboat, train
195
+
196
+ **Emotions** (2)
197
+ smile, thumbs-up
198
+
199
+ Icon file names use kebab-case (e.g. `shopping-bag.svg`, `thumbs-up.svg`), while React component names use PascalCase with an `Icon` suffix (e.g. `ShoppingBagIcon`, `ThumbsUpIcon`).
200
+
201
+ ## Design Principles
202
+
203
+ Naive Icons follows four fixed rules. They should be respected when adding new icons.
204
+
205
+ 1. **Grid & bleed**: All graphics are drawn on a 48x48 canvas, keeping at least 3 units between the main body and the canvas edge.
206
+ 2. **Stroke**: A unified 3.5 width with round caps and joins, and no dashed lines.
207
+ 3. **Color**: Use only the 9 colors in the palette — no gradients, shadows, or semi-transparent overlays.
208
+ 4. **Personality**: Slight asymmetry is welcome; encourage dot eyes and a smile on living subjects to keep the hand-drawn clumsiness.
209
+
210
+ ## Directory Structure
211
+
212
+ ```
213
+ naive-icons/
214
+ ├── svg/ 101 SVG source files
215
+ ├── src/ 101 React TSX components + index.ts + types.ts
216
+ ├── assets/ Brand assets (logo)
217
+ ├── scripts/ Icon generation and preview build scripts
218
+ ├── website/ Official documentation site
219
+ ├── dist/ Build output (ESM + CJS + type declarations, not version-controlled)
220
+ ├── tsup.config.ts Build configuration
221
+ ├── tsconfig.json
222
+ ├── LICENSE
223
+ ├── README.md
224
+ ├── CHANGELOG.md
225
+ ├── CONTRIBUTING.md
226
+ └── package.json
227
+ ```
228
+
229
+ ## Local Development
230
+
231
+ ```bash
232
+ git clone https://github.com/guokaigdg/naive-icons.git
233
+ cd naive-icons
234
+ npm install
235
+ ```
236
+
237
+ Common scripts:
238
+
239
+ ```bash
240
+ npm run build # Build dist with tsup (ESM + CJS + type declarations)
241
+ npm run dev # Watch mode build
242
+ npm run typecheck # Type check
243
+ npm run website # Preview the site locally (Python static server, port 8080)
244
+ npm run icons:build # Regenerate SVG and TSX from script definitions
245
+ npm run icons:add # Incrementally add icons without overwriting existing files
246
+ ```
247
+
248
+ `prepublishOnly` runs the build automatically on publish, so there is no need to run `npm run build` manually.
249
+
250
+ The build output is `dist/index.mjs` (ESM), `dist/index.js` (CJS), and `dist/index.d.ts` / `dist/index.d.mts` (type declarations). The `exports` field in `package.json` points to the correct file for each `import` / `require` condition. React is declared as external and is not bundled.
251
+
252
+ The website is a fully static site (no build step, no dependencies). You can open `website/index.html` directly: browse all icons, filter by category, search, adjust size and stroke color live, switch between light/dark/grid preview backgrounds, and click any icon to view React usage, copy code, or download the SVG. It supports light/dark themes (follows the system, with manual toggle remembered) and lets you navigate between icons with arrow keys in the modal.
253
+
254
+ ## Fonts
255
+
256
+ The icon library itself (SVG and React components) has no font dependency. The website additionally loads a hand-written-style font for headings and body text: [LXGW Yozai](https://github.com/lxgw/yozai-font) (SIL Open Font License 1.1, free for commercial use).
257
+
258
+ The website self-hosts the font: it only bundles the characters actually used on the site (about 715 characters, roughly 170 KB for the regular weight), fully offline. Files live in `website/assets/fonts/`. To regenerate the subset yourself, run:
259
+
260
+ ```bash
261
+ python3 scripts/subset_fonts.py
262
+ ```
263
+
264
+ It depends on `fonttools` and `brotli`:
265
+
266
+ ```bash
267
+ pip install fonttools brotli
268
+ ```
269
+
270
+ ## Browser Support
271
+
272
+ Naive Icons outputs standard SVG 1.1 and supports all modern browsers (the last two major versions of Chrome, Firefox, Safari, and Edge). The React components contain no browser-specific APIs and can be safely used in server-side rendering environments.
273
+
274
+ ## License
275
+
276
+ MIT License. See [LICENSE](./LICENSE).
277
+
278
+ All icons are original works, free to use in personal and commercial projects without attribution.
package/README.md ADDED
@@ -0,0 +1,278 @@
1
+ <p align="right">
2
+ <a href="./README.md">中文</a> | <a href="./README.en.md">English</a>
3
+ </p>
4
+
5
+ <p align="center">
6
+ <img src="assets/logo.svg" alt="Naive Icons" width="132" height="132">
7
+ </p>
8
+
9
+ <h1 align="center">Naive Icons</h1>
10
+
11
+ <p align="center">手绘 naive folk art 风格的 SVG 图标库,为 React 与 TypeScript 打造</p>
12
+
13
+ Naive Icons 是一套手绘 naive folk art 风格的 SVG 图标库,为 React 与 TypeScript 打造。全部 101 个图标由 AI 生成,均为原创作品。
14
+
15
+ 每一个图标都建立在 48x48 的网格上,使用 3.5 的粗描边、圆角线帽与统一的复古调色板,并保留了手绘插画特有的笨拙感与温度——部分图标还带有一对小圆点眼睛和微笑,让界面多一点点人情味。
16
+
17
+ - 图标数量:101
18
+ - 单个体积:约 400 至 700 字节
19
+ - 依赖:零运行时依赖,仅 peer 依赖 React
20
+ - 许可证:MIT
21
+
22
+ ## 目录
23
+
24
+ - [特性](#特性)
25
+ - [安装](#安装)
26
+ - [快速开始](#快速开始)
27
+ - [组件属性](#组件属性)
28
+ - [直接使用 SVG](#直接使用-svg)
29
+ - [调色板](#调色板)
30
+ - [图标清单](#图标清单)
31
+ - [设计原则](#设计原则)
32
+ - [目录结构](#目录结构)
33
+ - [本地开发](#本地开发)
34
+ - [浏览器支持](#浏览器支持)
35
+ - [许可证](#许可证)
36
+
37
+ ## 特性
38
+
39
+ - 101 个手绘风格的原创 SVG 图标,覆盖界面、操作、媒体、导航、动物、食物等 11 个分类
40
+ - 统一规格:48x48 viewBox、3.5 描边宽度、round 线帽与线角
41
+ - 统一调色板:9 色复古配色,可作为设计令牌直接引用
42
+ - 部分图标带有圆点眼睛与微笑表情,风格辨识度高
43
+ - 每个图标同时提供 SVG 源文件与 React TSX 组件
44
+ - 完整 TypeScript 类型:IconProps、IconName、IconCategory、NAIVE_PALETTE
45
+ - 透明背景、无渐变、无外部字体依赖
46
+ - 支持 currentColor,可跟随文字颜色自动变化
47
+
48
+ ## 安装
49
+
50
+ ```bash
51
+ npm install naive-icons
52
+ ```
53
+
54
+ ```bash
55
+ yarn add naive-icons
56
+ ```
57
+
58
+ ```bash
59
+ pnpm add naive-icons
60
+ ```
61
+
62
+ Naive Icons 只依赖 React,支持 React 16.8 及以上版本(含 React 18 与 19)。
63
+
64
+ ## 快速开始
65
+
66
+ ```tsx
67
+ import { HomeIcon, HeartIcon, PenguinIcon } from 'naive-icons';
68
+
69
+ export function Example() {
70
+ return (
71
+ <nav>
72
+ <HomeIcon size={24} />
73
+ <HeartIcon size={24} color="#E76F51" />
74
+ <PenguinIcon size={48} strokeWidth={4} />
75
+ </nav>
76
+ );
77
+ }
78
+ ```
79
+
80
+ 按需引入可以进一步减小打包体积:
81
+
82
+ ```tsx
83
+ import HomeIcon from 'naive-icons/src/HomeIcon';
84
+ ```
85
+
86
+ 配合 currentColor 使用,图标会自动继承父级文字颜色:
87
+
88
+ ```tsx
89
+ <span style={{ color: '#264653' }}>
90
+ <HomeIcon size={20} />
91
+ 首页
92
+ </span>
93
+ ```
94
+
95
+ 添加无障碍标题:
96
+
97
+ ```tsx
98
+ <HomeIcon size={24} title="返回首页" />
99
+ ```
100
+
101
+ ## 组件属性
102
+
103
+ Naive Icons 的每个组件都继承原生 `SVGProps<SVGSVGElement>`,可以直接传入 `className`、`onClick`、`style` 等任意 SVG 属性。
104
+
105
+ | 属性 | 类型 | 默认值 | 说明 |
106
+ | --- | --- | --- | --- |
107
+ | size | number \| string | 24 | 图标尺寸,宽高相等。传入后覆盖 width 与 height |
108
+ | color | string | currentColor | 描边颜色 |
109
+ | strokeWidth | number \| string | 3.5 | 描边宽度,按 48x48 画布比例缩放 |
110
+ | fill | string | none | 填充色 |
111
+ | title | string | — | 无障碍标题,渲染为 SVG title 节点 |
112
+ | width / height | number \| string | 跟随 size | 单独指定宽或高 |
113
+
114
+ ```typescript
115
+ import type { IconProps } from 'naive-icons';
116
+
117
+ interface IconProps extends SVGProps<SVGSVGElement> {
118
+ size?: number | string;
119
+ color?: string;
120
+ strokeWidth?: number | string;
121
+ fill?: string;
122
+ title?: string;
123
+ }
124
+ ```
125
+
126
+ ## 直接使用 SVG
127
+
128
+ 如果项目不是 React,可以直接使用 `svg/` 目录下的源文件。所有 SVG 都是自包含的,没有外部引用。
129
+
130
+ ```html
131
+ <img src="naive-icons/svg/home.svg" width="24" height="24" alt="首页" />
132
+ ```
133
+
134
+ 内联使用时,把 `stroke="#2A2A2A"` 替换为 `stroke="currentColor"` 即可跟随文字颜色:
135
+
136
+ ```html
137
+ <svg viewBox="0 0 48 48" width="24" height="24" fill="none"
138
+ stroke="currentColor" stroke-width="3.5"
139
+ stroke-linecap="round" stroke-linejoin="round">
140
+ <!-- 复制 svg/home.svg 中的 path 内容 -->
141
+ </svg>
142
+ ```
143
+
144
+ 也可以做成 SVG sprite 或 Icon Font,源文件结构足够简单,便于二次加工。
145
+
146
+ ## 调色板
147
+
148
+ ```typescript
149
+ import { NAIVE_PALETTE } from 'naive-icons';
150
+ ```
151
+
152
+ | 名称 | 色值 | 用途 |
153
+ | --- | --- | --- |
154
+ | ink | #2A2A2A | 主描边色 |
155
+ | navy | #264653 | 深色主体 |
156
+ | orange | #E76F51 | 强调色 |
157
+ | yellow | #E9C46A | 暖色填充 |
158
+ | pink | #F4A6A4 | 柔和填充 |
159
+ | green | #588157 | 自然元素 |
160
+ | teal | #2A9D8F | 辅助色 |
161
+ | brown | #8B5E3C | 木质与土地 |
162
+ | cream | #FAEDCD | 浅色底 |
163
+
164
+ ## 图标清单
165
+
166
+ **界面基础**(13)
167
+ home, user, settings, search, heart, star, bell, calendar, clock, eye, bulb, tag, bookmark
168
+
169
+ **操作**(11)
170
+ edit, trash, download, upload, save, plus, close, check, refresh, share, play
171
+
172
+ **文件与媒体**(9)
173
+ file, folder, image, camera, video, mic, music, code, book
174
+
175
+ **导航方位**(6)
176
+ location, compass, map, flag, anchor, magnet
177
+
178
+ **通信**(4)
179
+ mail, chat, phone, wifi
180
+
181
+ **自然天气**(12)
182
+ sun, moon, cloud, umbrella, tree, flower, leaf, rainbow, mushroom, cactus, snowflake, flame
183
+
184
+ **动物**(14)
185
+ cat, dog, bird, fish, penguin, rabbit, bear, fox, owl, frog, bee, butterfly, snail, ladybug
186
+
187
+ **食物饮品**(9)
188
+ apple, strawberry, watermelon, cherry, lemon, cake, icecream, donut, coffee
189
+
190
+ **日常物品**(13)
191
+ balloon, lamp, candle, pencil, paintbrush, globe, trophy, shopping-bag, credit-card, gift, thermometer, lock, key
192
+
193
+ **交通工具**(7)
194
+ car, airplane, rocket, cart, bicycle, sailboat, train
195
+
196
+ **表情**(2)
197
+ smile, thumbs-up
198
+
199
+ 图标文件名使用 kebab-case(如 `shopping-bag.svg`、`thumbs-up.svg`),React 组件名使用 PascalCase 并带 Icon 后缀(如 `ShoppingBagIcon`、`ThumbsUpIcon`)。
200
+
201
+ ## 设计原则
202
+
203
+ Naive Icons 遵循四条固定规则,新增图标时也应保持一致。
204
+
205
+ 1. **网格与出血**:全部图形绘制在 48x48 画布内,主体距离画布边缘至少保留 3 个单位。
206
+ 2. **描边**:统一 3.5 宽度,端点与转角均为 round,不使用虚线。
207
+ 3. **配色**:只使用调色板中的 9 个颜色,不使用渐变、阴影与半透明叠加。
208
+ 4. **性格**:允许线条轻微不对称,鼓励给有生命的图形加上圆点眼睛与微笑,保留手绘的笨拙感。
209
+
210
+ ## 目录结构
211
+
212
+ ```
213
+ naive-icons/
214
+ ├── svg/ 101 个 SVG 源文件
215
+ ├── src/ 101 个 React TSX 组件 + index.ts + types.ts
216
+ ├── assets/ 品牌资源(logo)
217
+ ├── scripts/ 图标生成与预览构建脚本
218
+ ├── website/ 官方文档站点
219
+ ├── dist/ 构建产物(ESM + CJS + 类型声明,不纳入版本控制)
220
+ ├── tsup.config.ts 构建配置
221
+ ├── tsconfig.json
222
+ ├── LICENSE
223
+ ├── README.md
224
+ ├── CHANGELOG.md
225
+ ├── CONTRIBUTING.md
226
+ └── package.json
227
+ ```
228
+
229
+ ## 本地开发
230
+
231
+ ```bash
232
+ git clone https://github.com/guokaigdg/naive-icons.git
233
+ cd naive-icons
234
+ npm install
235
+ ```
236
+
237
+ 常用脚本:
238
+
239
+ ```bash
240
+ npm run build # 用 tsup 构建 dist(ESM + CJS + 类型声明)
241
+ npm run dev # 监听模式构建
242
+ npm run typecheck # 类型检查
243
+ npm run website # 本地预览官网(Python 静态服务器,端口 8080)
244
+ npm run icons:build # 依据 scripts 中的定义重新生成 SVG 与 TSX
245
+ npm run icons:add # 增量新增图标,不覆盖已有文件
246
+ ```
247
+
248
+ 发布时 `prepublishOnly` 会自动执行构建,无需手动运行 `npm run build`。
249
+
250
+ 构建产物为 `dist/index.mjs`(ESM)、`dist/index.js`(CJS)与 `dist/index.d.ts` / `dist/index.d.mts`(类型声明),`package.json` 的 `exports` 已按 `import` / `require` 条件分别指向对应文件。React 被声明为 external,不会被打进产物。
251
+
252
+ 官网是纯静态站点(无构建、无依赖),直接打开 `website/index.html` 也能用:浏览全部图标、按分类筛选、搜索、实时调整尺寸与描边颜色、切换浅色/深色/网格预览底,点击任意图标可查看 React 用法、复制代码或下载 SVG。支持浅色 / 深色主题(跟随系统、可手动切换并记忆),弹窗内可用方向键连续切换图标。
253
+
254
+ ## 字体
255
+
256
+ 图标库本体(SVG 与 React 组件)不依赖任何字体。官网额外引入一款手写感字体用于标题与正文:[LXGW 悠哉字体](https://github.com/lxgw/yozai-font)(SIL Open Font License 1.1,可自由商用)。
257
+
258
+ 官网自托管方式:仅打包站内实际用到的字符(约 715 个,常规字重约 170 KB),完全离线可用,文件位于 `website/assets/fonts/`。如需自行重新生成子集,运行:
259
+
260
+ ```bash
261
+ python3 scripts/subset_fonts.py
262
+ ```
263
+
264
+ 依赖 `fonttools` 与 `brotli`:
265
+
266
+ ```bash
267
+ pip install fonttools brotli
268
+ ```
269
+
270
+ ## 浏览器支持
271
+
272
+ Naive Icons 输出的是标准 SVG 1.1,支持所有现代浏览器(Chrome、Firefox、Safari、Edge 最近两个大版本)。React 组件不含任何浏览器专有 API,可在服务端渲染环境中安全使用。
273
+
274
+ ## 许可证
275
+
276
+ MIT License。详见 [LICENSE](./LICENSE)。
277
+
278
+ 全部图标均为原创作品,可自由用于个人与商业项目,无需署名。
@@ -0,0 +1,11 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="512" height="512" role="img" aria-labelledby="title">
2
+ <title id="title">Naive Icons</title>
3
+ <rect x="12" y="12" width="488" height="488" rx="116" fill="#E9C46A" stroke="#264653" stroke-width="24" stroke-linejoin="round"/>
4
+ <g transform="translate(256 256) scale(0.82) translate(-256 -256) translate(0 -10)">
5
+ <path d="M256 85 L341 235 L459 235 L363 331 L395 448 L256 363 L117 448 L149 331 L53 235 L171 235 Z"
6
+ fill="#E76F51" stroke="#264653" stroke-width="24" stroke-linejoin="round" stroke-linecap="round"/>
7
+ <circle cx="204" cy="266" r="22" fill="#264653"/>
8
+ <circle cx="308" cy="266" r="22" fill="#264653"/>
9
+ <path d="M214 330 Q256 372 298 330" fill="none" stroke="#264653" stroke-width="28" stroke-linecap="round"/>
10
+ </g>
11
+ </svg>