@aleph-alpha/config-css

中文文档
1.2.1发布于 2026/06/16Apache-2.0TypeScriptES Module近 30 天下载 1.4万

@aleph-alpha/config-css-preset

原始使用文档
文档目录12 节
  1. Config CSS Preset
  2. Installation
  3. Usage
  4. How to use
  5. Dark Theme
  6. Development
  7. Explaination
  8. Font Conversion Utility
  9. Usage
  10. Example
  11. Config CSS Preset helps in UI Customization
  12. References

Config CSS Preset

@aleph-alpha/config-css-preset

This package provides a basic configuration preset for CSS. It includes a set of default styles and configurations that can be easily customized to fit your project's needs.

Installation

To integrate this package into your project, Install the package using a package manager e.g pnpm:

pnpm add @aleph-alpha/config-css-preset

Usage

To use the preset in your project, follow these steps:

CSS Setup

You need to set up UnoCSS in your project. UnoCSS is a utility-first CSS framework that allows for a more efficient and consistent styling approach.

For detailed instructions on setting up UnoCSS, please refer to the UnoCSS Installation Guide. This guide will walk you through the process of installing UnoCSS and configuring it for your project.

After setting up UnoCSS, you need to add the Aleph Alpha CSS preset to your UnoCSS configuration.

// unocss.config.ts
import { defineConfig } from 'unocss';

import { presetAlephAlpha, designSystemContentPathConfig } from '@aleph-alpha/config-css-preset';
import { presetAlephAlphaIcons } from '@aleph-alpha/ds-icons';

export default defineConfig({
  ...getDesignSystemContentPathConfig('svelte' | 'vue'),
  presets: [presetAlephAlpha()],
});

How to use

All available design tokens are defined here tokens. Use the design tokens in your project as following:

<p class="color-core-content-primary">color-core-content-primary</p>
<div class="border-r-core-border-primary">border-r-core-border-primary</div>
<p class="label-12">label-12</p>
<div class="shadow-dropdowns">Dropdown Shadow</div>

Dark Theme

If you want to apply the dark theme, set a top level dark class, e.g. to the body tag

<body class="dark">
  <p class="color-core-content-primary">color-core-content-primary</p>
</body>

Development

To develop this package, clone the repository and run the following commands:

pnpm install
pnpm build

Explaination

The packages purpose is to take in Figma Tokens via the Figma Plugin Tokens Studio and transform it to be exposed as Tokens in UnoCss.

The build steps are as follows:

  1. Designer pushes token changes from Figma to a tokens.json file and opens a MR.
  2. When the MR is merged, the pipeline runs and triggers the build process.
  3. Tokens from tokens.json are transformed, split into different categories and stored in the transformed-tokens directory with token-transformer so that style dictionary can read them. Categories are light-mode, dark-mode and global
  4. The transformed tokens are then processed with style-dictionary to generate tokens that can be used in UnoCss. The processed tokens are stored in the sd-output directory.
  5. The processed tokens in sd-output are then used to create UnoCss presets.
  6. The UnoCss presets are then bundled up with vite and the final package is stored in the dist directory.
graph TD
    A[Designer pushes token changes from Figma to tokens.json] --> B[Open MR]
    B --> C{MR merged?}
    C -->|Yes| D[Pipeline runs]
    D --> E[Trigger build process]
    E --> F[Transform and split tokens with token-transformer]
    F --> G[Store transformed tokens in transformed-tokens directory]
    G --> H[Process tokens with style-dictionary]
    H --> I[Store processed tokens in sd-output directory]
    I --> J[Create UnoCss presets]
    J --> K[Bundle presets with Vite]
    K --> L[Store final package in dist directory]
    C -->|No| B
    subgraph Token Categories
        F --> F1[light-mode]
        F --> F2[dark-mode]
        F --> F3[global]
    end

Font Conversion Utility

This package includes a utility script for converting WOFF2 font files to TypeScript files with base64-encoded data. This is useful for embedding fonts directly in your application.

Usage

The convert-fonts.js script is located at packages/config-css-preset/src/utils/convert-fonts.js and can be used as follows:

node packages/config-css-preset/src/utils/convert-fonts.js <input.woff2> <output.ts>

Example

node packages/config-css-preset/src/utils/convert-fonts.js montserrat600.woff2 montserrat600.woff2.ts

This will:

  1. Read the WOFF2 font file
  2. Convert it to base64 format
  3. Generate a TypeScript file with an exported constant containing the base64 data
  4. The constant name is derived from the output filename

The generated TypeScript file will look like:

export const montserrat600 = 'data:font/woff2;base64,<base64-encoded-font-data>';

Config CSS Preset helps in UI Customization

Read more here

References

The following packages are used to generate the presets:

See the source code for details on the configuration of the Aleph Alpha CSS preset.

版本与发布记录

@aleph-alpha/config-css 共发布 234 个版本,首次发布于 2025/03/10;过去 12 个月发布了 86 个版本。

版本发布日期距今
1.2.1latest2026/06/164 个月前
1.2.02026/05/265 个月前
1.1.02026/05/115 个月前
1.0.02026/05/056 个月前
0.22.02026/04/136 个月前
0.21.22026/03/187 个月前

其他发布通道:canary → 0.18.14-canary.a3917b1a.0。

关于 @aleph-alpha/config-css 的常见问题

@aleph-alpha/config-css 是什么?

@aleph-alpha/config-css-preset

如何安装 @aleph-alpha/config-css?

在项目目录运行 npm install @aleph-alpha/config-css,或使用 pnpm add / yarn add / bun add。

@aleph-alpha/config-css 支持 TypeScript 吗?

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

@aleph-alpha/config-css 支持 ESM 还是 CommonJS?

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

@aleph-alpha/config-css 可以商用吗?

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

@aleph-alpha/config-css 的下载量有多少?

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

@aleph-alpha/config-css 还在维护吗?

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