@aleph-alpha/ui-library

中文文档
7.0.2发布于 2026/10/29Apache-2.0TypeScriptES Module近 30 天下载 1.7万

Next-gen UI Library for Vue.js projects.

原始使用文档
文档目录21 节
  1. Installation
  2. Required Peer Dependencies
  3. Usage
  4. 1. Configure UnoCSS
  5. Custom theme (via design tokens)
  6. 2. Configure Vite
  7. 3. Import Styles
  8. 4. Use Components
  9. Using with @aleph-alpha/ds-components-vue
  10. AI Assistant Integration
  11. External Resources
  12. Documentation
  13. Getting Started
  14. Node Version
  15. Developing
  16. Commit Messages
  17. Adding New Components
  18. Testing
  19. Pre-commit Workflow
  20. If commit hangs:
  21. Quick unblock (Emergency only)

UI Library

📘 View Storybook

Pull requests that touch ui-library run affected Storybook build and test checks in CI.

Installation

pnpm add @aleph-alpha/ui-library

Required Peer Dependencies

pnpm add -D unocss @unocss/preset-wind4 @unocss/reset unocss-preset-animations unocss-preset-shadcn

Usage

1. Configure UnoCSS

The library exports a helper function getUiLibraryContentConfig() to simplify UnoCSS configuration:

// uno.config.ts
import { defineConfig } from 'unocss';
import { getUiLibraryContentConfig } from '@aleph-alpha/ui-library/config';
import presetWind from '@unocss/preset-wind4';
import presetAnimations from 'unocss-preset-animations';
import presetShadcn from 'unocss-preset-shadcn';

export default defineConfig({
  ...getUiLibraryContentConfig(),
  presets: [
    presetWind(),
    presetAnimations(),
    presetShadcn({ color: 'neutral', darkSelector: 'html.dark' }),
  ],
});

Custom theme (via design tokens)

@aleph-alpha/ui-library uses shadcn-style semantic utilities such as bg-background, text-foreground, bg-primary, border-input, etc. These resolve through CSS variables (e.g. --background, --primary).

If you added/maintain tokens in packages/ui-library/tokens.json, you can load them directly:

// uno.config.ts
import { defineConfig } from 'unocss';
import {
  getUiLibraryContentConfig,
  presetUiLibraryThemeFromTokens,
} from '@aleph-alpha/ui-library/config';
import presetWind from '@unocss/preset-wind4';
import presetAnimations from 'unocss-preset-animations';
import presetShadcn from 'unocss-preset-shadcn';

export default defineConfig({
  ...getUiLibraryContentConfig(),
  presets: [
    presetWind(),
    presetAnimations(),
    presetShadcn({ color: 'neutral', darkSelector: 'html.dark' }),
    // Put the theme preset AFTER shadcn so it overrides shadcn's default CSS vars
    presetUiLibraryThemeFromTokens(),
  ],
});

Option B: Provide your own shadcn vars explicitly

To implement a custom theme from your token values, add presetUiLibraryTheme() after presetShadcn() so it overrides shadcn's default CSS vars:

// uno.config.ts
import { defineConfig } from 'unocss';
import {
  getUiLibraryContentConfig,
  presetUiLibraryTheme,
} from '@aleph-alpha/ui-library/config';
import presetWind from '@unocss/preset-wind4';
import presetAnimations from 'unocss-preset-animations';
import presetShadcn from 'unocss-preset-shadcn';

export default defineConfig({
  ...getUiLibraryContentConfig(),
  presets: [
    presetWind(),
    presetAnimations(),
    presetShadcn({ color: 'neutral', darkSelector: 'html.dark' }),
    presetUiLibraryTheme({
      light: {
        // shadcn vars (keys without the leading `--`)
        background: '0 0% 100%',
        foreground: '240 10% 3.9%',
        primary: '222.2 47.4% 11.2%',
        'primary-foreground': '210 40% 98%',
        border: '240 5.9% 90%',
        input: '240 5.9% 90%',
        ring: '240 5.9% 10%',
      },
      dark: {
        background: '240 10% 3.9%',
        foreground: '0 0% 98%',
        primary: '210 40% 98%',
        'primary-foreground': '222.2 47.4% 11.2%',
        border: '240 3.7% 15.9%',
        input: '240 3.7% 15.9%',
        ring: '240 4.9% 83.9%',
      },
    }),
  ],
});

Notes:

  • Value formats: You can pass OKLCH components, or hex/rgb(...)/hsl(...) — they will be converted to shadcn-compatible OKLCH components.
  • Dark mode selector: Defaults to html.dark. If your app uses .dark on another element, pass { darkSelector: '.dark' } as the second argument.

2. Configure Vite

// vite.config.ts
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import UnoCSS from 'unocss/vite';

export default defineConfig({
  plugins: [vue(), UnoCSS()],
});

3. Import Styles

// main.ts
import '@unocss/reset/tailwind.css';
import 'virtual:uno.css';

import { createApp } from 'vue';
import App from './App.vue';

createApp(App).mount('#app');

4. Use Components

<script setup lang="ts">
import { UiButton, UiBadge } from '@aleph-alpha/ui-library';
</script>

<template>
  <UiButton>Click me</UiButton>
  <UiBadge variant="secondary">New</UiBadge>
</template>

Using with @aleph-alpha/ds-components-vue

Deprecated package: @aleph-alpha/ds-components-vue is deprecated. Use this coexistence setup only while migrating existing Aa* usage to @aleph-alpha/ui-library; do not add it to new applications.

If you're using both ui-library and ds-components-vue, configure UnoCSS to include both:

⚠️ Important: Do NOT add presetWind() or presetAnimations() separately when using presetsAlephAlpha(). The DS presets already include these utilities. Adding them again from different packages causes style conflicts.

// uno.config.ts
import { defineConfig } from 'unocss'
import { presetsAlephAlpha, getDesignSystemContentPathConfig } from '@aleph-alpha/config-unocss'
import { getUiLibraryContentConfig } from '@aleph-alpha/ui-library/config'
import presetShadcn from 'unocss-preset-shadcn'

const uiLibraryConfig = getUiLibraryContentConfig();
const dsConfig = getDesignSystemContentPathConfig('vue');

export default defineConfig({
  presets: [
    // DS presets (already includes presetWind + presetAnimations)
    ...presetsAlephAlpha(),
    // UI Library preset (for shadcn CSS variables only)
    presetShadcn({ color: 'neutral' }),
  ],
  content: {
    filesystem: [
      ...(uiLibraryConfig.content.filesystem || []),
      ...(dsConfig.content?.filesystem || []),
    ],
    pipeline: {
      include: [
        /\.(vue|svelte|[jt]sx|mdx?|astro|elm|php|phtml|html)($|\?)/,
        'src/**/*.{js,ts,vue}',
        'node_modules/@aleph-alpha/ui-library/**/*.js',
        'node_modules/@aleph-alpha/ds-components-vue/**/*.{js,ts}',
      ],
    },
  },
});

AI Assistant Integration

Enable component discovery for Claude Code or Cursor:

npx @aleph-alpha/ui-library mcp-install

For Cursor, add --cursor flag. Then restart your IDE.

Available tools:

  • list_components - Browse all components (optionally filter by name/category/description)
  • get_component_docs - Get full documentation for a component

External Resources

Documentation

Getting Started

Node Version

This project requires Node.js v22.13.0. Use nvm to switch to the correct version:

nvm use

This will automatically read the .nvmrc file in the repository root.

Developing

Commit Messages

We follow the Conventional Commits specification. Commit messages must be structured as follows:

<type>(<scope>): <description>

[optional body]

[optional footer(s)]

Types:

  • feat: A new feature
  • fix: A bug fix
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (formatting, etc.)
  • refactor: A code change that neither fixes a bug nor adds a feature
  • perf: A code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • chore: Changes to the build process or auxiliary tools

Examples:

git commit -m "feat(button): add loading state"
git commit -m "fix(dropdown): resolve keyboard navigation issue"
git commit -m "docs(readme): update installation instructions"

Adding New Components

To add a new component from shadcn-vue, use the following command:

pnpm dlx shadcn-vue@latest add [component]

Example:

pnpm dlx shadcn-vue@latest add tooltip

Run the CLI on Node 24 (nvm use 24) rather than the pinned 22.13.0, otherwise its dependencies abort with ERR_PNPM_UNSUPPORTED_ENGINE. Afterwards, repoint any generated @lucide/vue or lucide-vue-next icon import to @/icons/lucide, the library's single Lucide entry point.

Please refer to CONTRIBUTION_GUIDELINES.md for more details on the "Strict Facade" pattern and accessibility requirements.

Testing

CommandPurpose
pnpm testRun unit tests
pnpm test:storybookRun automated tests (play functions + a11y) against a build
pnpm test:storybook:localBuild Storybook, then run the automated tests
pnpm lintRun linting including a11y rules

Every component must ship both layers: unit tests and automated tests (play functions covering interaction, keyboard, zoom, screen reader, and mobile). See Testing Strategy.

Pre-commit Workflow

This project uses nx affected in pre-commit hooks to ensure code quality. Because lint and test targets depend on build, commits might hang if the build cache is cold.

If commit hangs:

Run a full build to populate the cache before committing:

pnpm nx run-many --target=build --all

Then try committing again. The pre-commit hook will hit the cache and finish quickly.

Quick unblock (Emergency only)

If you need to bypass hooks:

git commit -m "Your message" --no-verify

Use this sparingly and ensure CI passes.

版本与发布记录

@aleph-alpha/ui-library 共发布 84 个版本,首次发布于 2025/12/18;过去 12 个月发布了 84 个版本。

版本发布日期距今
7.0.2latest2026/10/297 天前
7.0.12026/10/2610 天前
7.0.02026/10/2610 天前
6.6.02026/10/2413 天前
6.5.02026/10/2313 天前
6.4.02026/10/1917 天前

关于 @aleph-alpha/ui-library 的常见问题

@aleph-alpha/ui-library 是什么?

Next-gen UI Library for Vue.js projects.

如何安装 @aleph-alpha/ui-library?

在项目目录运行 npm install @aleph-alpha/ui-library,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:unocss(>=66.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@aleph-alpha/ui-library 支持 TypeScript 吗?

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

@aleph-alpha/ui-library 支持 ESM 还是 CommonJS?

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

@aleph-alpha/ui-library 需要什么版本的 Node.js?

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

@aleph-alpha/ui-library 可以商用吗?

@aleph-alpha/ui-library 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@aleph-alpha/ui-library 的下载量有多少?

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

@aleph-alpha/ui-library 还在维护吗?

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