项目 / carbon-design-system/carbon-icons-svelte
carbon-design-system/carbon-icons-svelte
行业推荐
语言 TypeScript标签 ibmiconscarboncarbon-design-systemsveltecomponentssvgsvelte-componentssvg-iconstypescript-definitions数据更新 2026-11-22 06:48:52 · 仓库 2026-11-21
一段话介绍
把 Carbon Design System 的 SVG 图标打包为 Svelte 组件的零依赖图标库。可与 carbon-components-svelte 一起使用,也可单独引入。安装和用法见仓库说明,预览页可查看图标效果。
本站整理,非 GitHub 官方 description。
官方 description(GitHub API 原样)Carbon Design System SVG icons as Svelte components
官方快照(gh_history.db,2026-11-25):总榜 未进 Top50 · 日榜 未进 Top50 · 周榜未满 7 天基线(官方不生成) · 月榜暂无官方口径;下方四卡为站内趋势聚合(周卡按上榜次数,非官方 7 日增量窗)。
能耗监测与能效优化
适配系统:能源管理系统、能耗监测平台 · 得分 1.4
面向能耗采集与负荷分析建模,可用于园区/楼宇能效诊断与用能优化建议。
更多信息
以下三段按该项目自己的 GitHub README 章节摘录(可合理截断并标明);README 没有对应章节的留空,不编造。
我的用法
安装或使用说明见 https://github.com/carbon-design-system/carbon-preprocess-svelte#optimizeimports。
特点或设计要点
图标按 Svelte 组件方式消费,不额外依赖其他运行时包。仓库提供 Svelte REPL 示例和在线预览;若需优化导入,源文指向 carbon-preprocess-svelte 中的 `optimizeImports`。官方图标清单可在 Carbon 设计系统图标库中查看。
星标走势还差一天的数据,明天就能看到曲线
每天 10:30 记一次星标,连续两天后自动生成曲线
GitHub 项目主页介绍
来自 GitHub 仓库 README / 主页介绍正文,原样摘录,共 4,193 字节。
# carbon-icons-svelte
[![NPM][npm]][npm-url]

> [Carbon Design System](https://github.com/carbon-design-system) SVG icons as Svelte components.
This zero dependency icon library builds [Carbon Design System icons](https://www.carbondesignsystem.com/elements/icons/library) as Svelte components. Although best paired with [carbon-components-svelte](https://github.com/carbon-design-system/carbon-components-svelte), these icons can be consumed standalone.
Try it in the [Svelte REPL](https://svelte.dev/repl/931e6a3461434622adad0557579c0a29).
## [Preview](https://carbon-icons-svelte.onrender.com) · [Icon Index](ICON_INDEX.md)
## Installation
```sh
# npm
npm i carbon-icons-svelte
# pnpm
pnpm i carbon-icons-svelte
# Yarn
yarn add carbon-icons-svelte
# Bun
bun add carbon-icons-svelte
```
## Usage
### Direct Import
Import the icon from the `carbon-icons-svelte/lib` folder. See the [Icon Index](ICON_INDEX.md) for a list of supported icons.
```svelte
<script>
import Add from "carbon-icons-svelte/lib/Add.svelte";
</script>
<Add />
```
### Base Import with Preprocessor
> [!TIP]
> Use [optimizeImports](https://github.com/carbon-design-system/carbon-preprocess-svelte#optimizeimports) from [carbon-preprocess-svelte](https://github.com/carbon-design-system/carbon-preprocess-svelte) to speed up development times.
Due to the size of the library, importing directly from the barrel file may result in slow development times, since the entire barrel file is imported (thousands of icons).
[optimizeImports](https://github.com/carbon-design-system/carbon-preprocess-svelte#optimizeimports) is a Svelte preprocessor that optimizes import paths from Carbon Svelte libraries. It enables you to use the barrel file import syntax without importing the entire library.
For example, the following is automatically re-written by `optimizeImports`:
```diff
- import { Add } from "carbon-icons-svelte";
+ import Add from "carbon-icons-svelte/lib/Add.svelte";
```
This offers the best of both worlds:
- Concise import syntax
- Fast development times (only the icons you need are imported)
### Custom size
Use the `size` prop to specify the icon size.
By design, the Carbon Design System uses a scale of 16, 20, 24, and 32 pixels for icons. However, you can still pass any number for `size` (pixels).
The default size is `16`.
```svelte
<Add size={16} />
<Add size={20} />
<Add size={24} />
<Add size={32} />
```
## API
All props are optional.
| Name | Type | Default value |
| :---- | :---------------------------------------------------------- | :------------ |
| size | <code>16 | 20 | 24 | 32 | number</code> | `16` |
| title | `string` | `undefined` |
### Custom props
`$$restProps` are forwarded to the `svg` element.
You can use `fill` to customize the color or pass any other valid `svg` attribute to the component.
```svelte
<Add fill="red" class="icon" />
```
### Labelled
```svelte
<Add aria-label="Add" />
```
### Labelled by
```svelte
<label id="add-file">Add file</label>
<Add aria-labelledby="add-file" />
```
### Focusable
```svelte
<Add aria-label="Add" tabindex={0} />
```
## TypeScript
This library offers TypeScript support for Svelte 4 and Svelte 5.
For Svelte 3 compatibility, use [`carbon-icons-svelte@12.13.0`](https://github.com/carbon-design-system/carbon-icons-svelte/tree/v12.13.0).
For convenience, a `CarbonIconProps` type is exported from the library.
```svelte
<script lang="ts">
import Add from "carbon-icons-svelte/lib/Add.svelte";
import type { CarbonIconProps } from "carbon-icons-svelte";
const props: CarbonIconProps = {
size: 16,
fill: "red",
"data-test": "id",
};
</script>
<Add {...props} />
```
## [Changelog](CHANGELOG.md)
## [Contributing](CONTRIBUTING.md)
## License
[Apache 2.0](LICENSE)
[npm]: https://img.shields.io/npm/v/carbon-icons-svelte.svg?color=262626&style=for-the-badge
[npm-url]: https://npmjs.com/package/carbon-icons-svelte