@castlabs/ui

中文文档
8.8.1发布于 2026/10/22TypeScriptCommonJS近 30 天下载 3064

A vanilla HTML/CS/JS & Vue.js component library for Castlabs.

原始使用文档
文档目录4 节
  1. Using @castlabs/ui in npm projects
  2. Using @castlabs/ui in Vue.js 3 projects
  3. Using @castlabs/ui in Angular projects
  4. Which .js file to use

castlabs-ui

This is a vanilla HTML and Vue.js component library for Castlabs branded sites.

Using @castlabs/ui in npm projects

This is a public NPM package, add it via:

  • npm install @castlabs/ui

Using @castlabs/ui in Vue.js 3 projects

Use the ui-boilerplate-vue demo project, it comes preconfigured with the UI lib.

Using @castlabs/ui in Angular projects

Follow the steps described above under Using @castlabs/ui in npm projects. Then edit your angular.json file and add the style files to your projects section:

"assets": [
  { "glob": "favicon.ico", "input": "node_modules/@castlabs/ui/dist/favicon", "output": "/" },
  { "glob": "favicon.svg", "input": "node_modules/@castlabs/ui/dist/favicon", "output": "/" },
  { "glob": "*", "input": "node_modules/@castlabs/ui/dist/favicon", "output": "favicon/" },
  "src/assets"
],
"styles": [
  "src/styles.scss"
],

Create/edit your src/style.scss file and add:

@use '@castlabs/ui/src/styles/ui' with (
  $castlabs-ui-asset-prefix: '../..'
);

To use our $cl-* helper SCSS variables in a component *.scss file, add to its top:

@use '@castlabs/ui/src/styles/global' as *;

To use our cl* helper js methods (csModalShow in the following examples), import them your TS files:

import { clModalShow } from '@castlabs/ui/dist/castlabs-ui.module.js'

You can use the helpers now in your code/template:

<!-- TS --->
export class ... {
  ...
  clModalShow = (id: string): void => clModalShow(id)
  ...
}

<!-- HTML --->
<button class="btn cl-color-red" (click)="clModalShow('mymodal')">click me</button>

Finally, it might or might not necessary to copy node_modules/@castlabs/ui/dist/castlabs-ui.module.d.ts over into your source tree for your local IDE to pick up all types. The angular builder should be able to fetch them directly from the node module.

Which .js file to use

There are multiple variants of our library js available. Depending on your needs:

  • castlabs-ui.core.js is used by static/vanilla JS projects that use

版本与发布记录

@castlabs/ui 共发布 117 个版本,首次发布于 2024/11/08;过去 12 个月发布了 58 个版本。

版本发布日期距今
8.8.1latest2026/10/2217 天前
8.8.02026/10/2020 天前
8.7.12026/10/081 个月前
8.7.02026/10/071 个月前
8.6.02026/09/241 个月前
8.5.42026/09/231 个月前

关于 @castlabs/ui 的常见问题

@castlabs/ui 是什么?

A vanilla HTML/CS/JS & Vue.js component library for Castlabs.

如何安装 @castlabs/ui?

在项目目录运行 npm install @castlabs/ui,或使用 pnpm add / yarn add / bun add。

@castlabs/ui 支持 TypeScript 吗?

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

@castlabs/ui 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@castlabs/ui 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js ^22.18.0 || >=24.12.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@castlabs/ui 可以商用吗?

@castlabs/ui 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@castlabs/ui 的下载量有多少?

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

@castlabs/ui 还在维护吗?

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