@canonical/ds-assets

中文文档
0.45.0发布于 2026/10/23LGPL-3.0TypeScriptES Module零依赖构建来源已验证近 30 天下载 1.1万

Assets for Pragma.

原始使用文档
文档目录6 节
  1. Installation
  2. Icons
  3. TypeScript Usage
  4. Finding an Icon
  5. SVG Files
  6. Fonts

@canonical/ds-assets

Icons, fonts, and shared visual assets for the Pragma design system.

Installation

bun add @canonical/ds-assets

Icons

The package provides over 150 SVG icons for interface actions, status indicators, navigation, and brand logos.

TypeScript Usage

Import the type-safe constant and type:

import { ICON_NAMES, type IconName } from "@canonical/ds-assets";

// Type-safe icon name
const iconName: IconName = "search";

// Validate user input
const isValidIcon = (name: string): name is IconName =>
  ICON_NAMES.includes(name as IconName);

Finding an Icon

ICON_METADATA carries the words people search for, so an icon picker can find delete when someone types "trash":

import { ICON_METADATA, ICON_CATEGORIES } from "@canonical/ds-assets";

ICON_METADATA.delete.tags; // ["trash", "bin", "remove", ...]
ICON_METADATA["starred-off"].aliases; // ["unstarred"]

Every icon has tags and at least one category from ICON_CATEGORIES; see docs/ICONS.md for the full shape.

SVG Files

Raw SVG files live in the icons/ directory. Each icon uses a 16x16 viewBox and currentColor fill, allowing icons to inherit text colour from their context.

Icons can be referenced directly via SVG's <use> element:

<svg width="16" height="16">
  <use href="path/to/search.svg#search" />
</svg>

See docs/ICONS.md for the complete icon specification, naming conventions, and migration notes from Vanilla.

Fonts

Variable woff2 fonts for Ubuntu Sans and Ubuntu Sans Mono live in fonts/ubuntu-sans/.

Source: canonical/Ubuntu-Sans-fonts (fonts/webfont/ — variable font builds).

License: The fonts/ubuntu-sans/ directory is licensed under the Ubuntu Font License v1.0, not LGPL like the rest of this package.

These fonts are consumed by @canonical/styles/fonts via @font-face declarations. You don't need to reference them directly unless building custom font loading.

版本与发布记录

@canonical/ds-assets 共发布 44 个版本,首次发布于 2025/09/25;过去 12 个月发布了 42 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.45.0latest2026/10/2317 天前
0.44.12026/10/081 个月前
0.44.02026/10/051 个月前
0.43.02026/10/011 个月前
0.42.02026/09/281 个月前
0.40.02026/09/211 个月前

关于 @canonical/ds-assets 的常见问题

@canonical/ds-assets 是什么?

Assets for Pragma.

如何安装 @canonical/ds-assets?

在项目目录运行 npm install @canonical/ds-assets,或使用 pnpm add / yarn add / bun add。

@canonical/ds-assets 支持 TypeScript 吗?

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

@canonical/ds-assets 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@canonical/ds-assets 可以商用吗?

@canonical/ds-assets 使用 LGPL-3.0 许可。弱 Copyleft:作为库被调用时通常不要求开源你自己的代码,但修改库本身需以 LGPL 开源;前端打包合并后的适用边界存在不同理解。以上为概括,不构成法律意见,请以许可原文为准。

@canonical/ds-assets 的下载量有多少?

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

@canonical/ds-assets 还在维护吗?

最新版本 0.45.0 发布于 2026/10/23(17 天前);至今共发布 44 个版本,其中过去 12 个月发布了 42 个;首次发布于 2025/09/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。