# @freightos/icons 中文文档

规范地址：https://npmcn.com/package/%40freightos/icons/

版本：3\.0\.1
npm 元数据更新时间：2026-04-05T13:01:29.243Z
中文译文更新时间：2026-11-16T00:17:28.968Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40freightos/icons
原文对照：https://npmcn.com/package/%40freightos/icons/?lang=original
项目主页：https://bitbucket.org/freightos/freightos-icons#readme

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：1.9 MB，849 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：0 个
- peer 依赖：react \>=16\.8\.0
- 首次发布：2025-11-01T20:46:06.957Z
- 最新版本发布：2026-04-05T13:01:29.114Z
- 近 30 天下载量：1976（2026-10-16 至 2026-11-14，npm 官方下载统计）
- 已发布版本数：20（近 12 个月 13 个）

## 中文简介

Frederos 应用程序的完整图标库, 并有完整的 TypeScript 支持

## 安装

```sh
npm install @freightos/icons
```

也可以使用：`pnpm add @freightos/icons`、`yarn add @freightos/icons`、`bun add @freightos/icons`

## README

# @freightos/相册

一个综合图标库,有280个SVG图标,为Frederos应用程序所设计. 由React所建,TypeScript所建,并铭记开发者的经验.

这个包裹住在 [货运窗口](https://freightwind.freightos.com/) 单重键 : `packages/icons/`。 。 。 .

## 特征

-   🎨 **280 图标** - 全套专业设计的图标
-   📦 **树能震动** - 只导入你需要的东西
-   🔷 **类型脚本第一** - 包括全部类型定义
-   ⚡ **双格式** - 包括无害环境管理和共同司法体系建设
-   🎯 **语义大小** - 使用( I) `xs` (12页x), `sm` (16个px), `md` (24个px), `lg` (32px)或任何数字/字符串
-   🎨 **可主题** - 用途 `currentColor` 以容易为目的
-   ♿ **可访问** - 通过SVG道具提供适当的ARIA支助
-   🪶 **轻巧** - 个人图标很小
-   ⚛️ **反应 16.8+** - 使用钩子和现代反应

## 安装

```bash
npm install @freightos/icons
# or
yarn add @freightos/icons
# or
pnpm add @freightos/icons
```

> **Monorepo 用户 :** 在FrederWind repo内,图标通过 `workspace:*` - 不需要安装.

## 使用指南

### 基本用途

直接从包中导入图标 :

```tsx
import { IconSearch, IconUser, IconDashboard } from '@freightos/icons';

function MyComponent() {
  return (
    <div>
      <IconSearch size={24} />
      <IconUser color="blue" />
      <IconDashboard className="my-icon" />
    </div>
  );
}
```

### 道具

所有图标接受以下道具:

| Prop | 类型 | 默认 | 说明 |
| --- | --- | --- | --- |
| `size` | `IconSize | number | string` | `'1em'` | 宽度和高度——语义符号(`xs`, (中文(简体) ), `sm`, (中文(简体) ), `md`, (中文(简体) ), `lg`),像素数字,或 CSS 字符串 |
| `color` | `FreightosColor | string` | `'currentColor'` | 图标的颜色 - 支持具有自动完成或任何 CSS 颜色值的设计系统颜色 |
| `className` | `string` | \- 说吧 | 补充CSS类 |
| `...props` | `SVGProps<SVGSVGElement>` | \- 说吧 | 任何有效的 SVG 属性 |

### 大小

图标默认是响应的,并且与母字体大小相适应。 可以多种方式自定义大小 :

```tsx
// Default size (1em - scales with font-size)
<IconSearch />

// Numeric size (pixels)
<IconSearch size={24} />
<IconSearch size={32} />

// String size (CSS units)
<IconSearch size="2rem" />
<IconSearch size="24px" />

// Responsive with parent font-size
<div className="text-lg">
  <IconSearch /> {/* Icon automatically scales */}
</div>

// Using CSS classes (Tailwind example)
<IconSearch className="w-6 h-6" />
```

### 颜色

图标使用 `currentColor` 默认,使其易于主题。 这个 `color` 道克支持 Frederos 设计系统颜色并带有自动完成,加上任何 CSS 颜色值 :

```tsx
// Freightos design system colors (with autocomplete!)
<IconSearch color="blue" />
<IconError color="red" />
<IconWarning color="yellow" />
<IconSuccess color="green" />

// Inherits parent text color
<div className="text-blue-500">
  <IconSearch />
</div>

// Any CSS color value
<IconSearch color="#1890ff" />
<IconSearch color="var(--primary-color)" />

// Using CSS classes
<IconSearch className="text-blue-500" />
<IconSearch className="text-gray-900 dark:text-white" />
```

#### 可用的设计系统颜色

下列Frederos设计系统颜色可自动支持:

**蓝:** `blue-10`, (中文(简体) ), `blue-20`, (中文(简体) ), `blue`, (中文(简体) ), `blue-40`, (中文(简体) ), `blue-50`

**红:** `red-10`, (中文(简体) ), `red-20`, (中文(简体) ), `red`, (中文(简体) ), `red-40`, (中文(简体) ), `red-50`

**黄:** `yellow-10`, (中文(简体) ), `yellow-20`, (中文(简体) ), `yellow`, (中文(简体) ), `yellow-30`, (中文(简体) ), `yellow-40`, (中文(简体) ), `yellow-50`

**绿:** `green-10`, (中文(简体) ), `green-20`, (中文(简体) ), `green`, (中文(简体) ), `green-40`, (中文(简体) ), `green-50`

**灰色:** `white`, (中文(简体) ), `gray-05`, (中文(简体) ), `gray-10`, (中文(简体) ), `gray-20`, (中文(简体) ), `gray-30`, (中文(简体) ), `gray-40`, (中文(简体) ), `gray-50`, (中文(简体) ), `gray-60`, (中文(简体) ), `gray-70`, (中文(简体) ), `gray-80`, (中文(简体) ), `gray-90`, (中文(简体) ), `gray`

**紫外线:** `purple-10`, (中文(简体) ), `purple`

**特殊 :** `transparent`

### 交互式图标

```tsx
// With click handler
<IconSearch
  onClick={() => console.log('Search clicked')}
  className="cursor-pointer"
/>

// With hover effects
<IconSearch className="hover:text-blue-500 transition-colors" />

// As a button
<button>
  <IconSearch size={20} />
  Search
</button>
```

### 使用参考文献

```tsx
import { useRef } from 'react';
import { IconSearch } from '@freightos/icons';

function Component() {
  const iconRef = useRef<SVGSVGElement>(null);

  return <IconSearch ref={iconRef} />;
}
```

## 类型脚本支持

### 使用图标类型

这个 `Icon` 类型允许您创建具有图标组件的类型安全变量:

```typescript
import { Icon, IconSearch, IconUser, IconDashboard } from '@freightos/icons';

// Define an interface with an icon property
interface NavItem {
  title: string;
  icon: Icon;  // Type for icon components
  path: string;
}

// Assign icon components (not JSX elements)
const navItems: NavItem[] = [
  { title: 'Search', icon: IconSearch, path: '/search' },
  { title: 'Profile', icon: IconUser, path: '/profile' },
  { title: 'Dashboard', icon: IconDashboard, path: '/dashboard' },
];

// Use in your component
function Navigation() {
  return (
    <nav>
      {navItems.map(item => {
        const IconComponent = item.icon;
        return (
          <a key={item.title} href={item.path}>
            <IconComponent size={20} />
            <span>{item.title}</span>
          </a>
        );
      })}
    </nav>
  );
}
```

### 动态图标选择

```typescript
import { Icon, IconSearch, IconUser, IconDashboard } from '@freightos/icons';

const iconMap: Record<string, Icon> = {
  search: IconSearch,
  user: IconUser,
  dashboard: IconDashboard,
};

function DynamicIcon({ name }: { name: string }) {
  const IconComponent = iconMap[name];

  if (!IconComponent) {
    console.warn(`Icon "${name}" not found`);
    return null;
  }

  return <IconComponent size={24} />;
}
```

## 可用图标

所有217个图标均可使用,按类别排列:

-   **导航**:搜索,菜单打开,菜单关闭,ArrowBack,ArrowForward,CaretUp,CaretDown等.
-   **行动**: 编辑、 回收站、 保存、 复制、 检查、 关闭、 附加、 最小值、 刷新等 .
-   **运输**: ModeAir,ModeShip,ModeTruck,ModeTrain,ModeAirExpress等.
-   **商业**:公司,工厂,仓库,办公室,账单,工资,钱库等.
-   **通讯**: 消息、呼叫、信封、聊天进展、通知 钟等.
-   **用户**:用户,用户循环,People,AddPerson等.
-   **状态**:警报循环、信息循环、检查循环、核实、等待等.
-   **文档**:文档,文档,下载,上传,存档,附件等.
-   **接口**: Dashboard,设置,过滤器,列表,网格,表格,平板等.
-   **后勤**: 集装箱,盒子,花板,克勒特,海关,保险,港口等.

参见您的 IDE 自动完成所有217 图标的完整列表 .

## 图标命名公约

图标遵循一致的命名模式:

-   SVG 文件名 : `search.svg` • 构成部分: `IconSearch`
-   SVG 文件名 : `menu-open.svg` • 构成部分: `IconMenuOpen`
-   SVG 文件名 : `mode-air-express.svg` • 构成部分: `IconModeAirExpress`

## 发展

### 添加新图标

1.  将您的 SVG 文件添加到 `packages/icons/svg/` (使用 kebab 大小写命名 : `my-icon.svg`(中文(简体) )
2.  生成反应组件 :

```bash
pnpm --filter @freightos/icons run generate
```

这将:

-   在 `src/icons/`
-   用导出更新索引文件
-   将硬码颜色替换为 `currentColor`

3.  构建软件包 :

```bash
pnpm --filter @freightos/icons run build
```

### 可用的脚本

```bash
# Generate icons from SVG files
pnpm --filter @freightos/icons run generate

# Build all formats (ESM + CJS + Types)
pnpm --filter @freightos/icons run build

# Generate and build in one command
pnpm --filter @freightos/icons run dev

# Clean build output
pnpm --filter @freightos/icons run clean
```

### 出版

软件包以 npm 的形式发布 `@freightos/icons`数字 :

```bash
pnpm --filter @freightos/icons run release:patch   # 1.0.12 → 1.0.13
pnpm --filter @freightos/icons run release:minor   # 1.0.12 → 1.1.0
pnpm --filter @freightos/icons run release:major   # 1.0.12 → 2.0.0
```

## 维护者

维护者 **吉里·纳斯拉维** (单位:千美元)[jiries @ freightos.com (法语)](mailto:jiries@freightos.com)(中文(简体) )

## 许可证

麻省理工学院

## 常见问题

### @freightos/icons 是什么？

Frederos 应用程序的完整图标库, 并有完整的 TypeScript 支持

### 如何安装 @freightos/icons？

在项目目录运行 npm install @freightos/icons，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：react（\>=16\.8\.0）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @freightos/icons 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @freightos/icons 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @freightos/icons 可以商用吗？

@freightos/icons 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @freightos/icons 的下载量有多少？

根据 npm 官方下载统计，@freightos/icons 在 2026/10/16 – 2026/11/14 这 30 天内被下载 1,976 次，日均约 66 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @freightos/icons 还在维护吗？

最新版本 3\.0\.1 发布于 2026/04/05（7 个月前）；至今共发布 20 个版本，其中过去 12 个月发布了 13 个；首次发布于 2025/11/02。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

