@aziontech/theme

中文文档
5.2.2发布于 2026/11/04MITES Module零依赖构建来源已验证近 30 天下载 7150

Azion's design-token system, compiled into a single Tailwind CSS v4 stylesheet: primitive palettes, brand colors, light/dark semantic tokens, the full text-style scale, motion utilities and @keyframes, and the @font-face set — plus the raw token d

原始使用文档
文档目录20 节
  1. Installation
  2. Quick start
  3. 1. Import the stylesheet
  4. 2. Switch themes
  5. Exports
  6. JavaScript token access
  7. Color primitives
  8. Motion primitives
  9. Text styles
  10. Semantic variables as JS (Node / build steps / runtime)
  11. CSS variables
  12. Token resolution
  13. Development
  14. Project structure
  15. Browser support
  16. Versioning
  17. Contributing
  18. License
  19. Links
  20. Changelog

@aziontech/theme

Azion's design-token system, compiled into a single Tailwind CSS v4 stylesheet: primitive palettes, brand colors, light/dark semantic tokens, the full text-style scale, motion utilities and @keyframes, and the @font-face set — plus the raw token data as importable JavaScript.

The package ships one prebuilt artifact (dist/v4/globals.css) and four small JS entry points. There is no Tailwind preset, plugin, or tailwind.config.js step — v4 reads the @theme / @utility definitions directly from the imported CSS.

Installation

npm install @aziontech/theme
# or
pnpm add @aziontech/theme
# or
yarn add @aziontech/theme

Tailwind CSS v4 must be present in the consuming build — the stylesheet begins with @import "tailwindcss".

Quick start

1. Import the stylesheet

In your app's root CSS:

@import '@aziontech/theme';

or from JavaScript (Vite and friends):

import '@aziontech/theme'

That single import provides:

  • the @font-face declarations for the Azion type system (no separate font imports needed);
  • every primitive CSS variable (colors, spacing, shape, typography, effects, breakpoints);
  • the semantic light/dark variables (--primary, --text-default, --surface-0…);
  • text-style utilities (text-heading-2xl, text-big-number-md, …) with responsive sizes;
  • animation utilities and their @keyframes (consumers pair every motion class with a motion-reduce: fallback).

2. Switch themes

Light is the default (:root). Dark mode activates on any of these hooks:

<html data-theme="dark">
  <!-- or -->
  <body class="dark">
    <!-- or the legacy pair -->
    <div class="azion azion-dark"></div>
  </body>
</html>
// Toggle at runtime
document.documentElement.dataset.theme = 'dark' // or 'light'

Light-mode selectors: :root, [data-theme='light'], .azion.azion-light. Dark-mode selectors: [data-theme='dark'], .dark, .azion.azion-dark.

Exports

The entire public surface, from package.json#exports:

PathWhat it is
@aziontech/themethe compiled stylesheet (dist/v4/globals.css)
@aziontech/theme/colorscolor primitives: primitives, brandPrimitives, surfacePrimitives
@aziontech/theme/animationsmotion primitives: animate, curve, duration, useWhen
@aziontech/theme/textstextsData — font-size/line-height/weight bundles per text style
@aziontech/theme/theme-colorssemantic compiler: compileThemeVars, compileThemeCss, injectThemeCss

JavaScript token access

Color primitives

import { primitives, brandPrimitives, surfacePrimitives } from '@aziontech/theme/colors'

primitives.orange[500] // '#F3652B' — primary brand
primitives.blue[500] // '#0072F5' — accent
primitives.violet[500] // '#8A84EC' — brand.accent palette
primitives.gray[900] // '#141414'

brandPrimitives.primary[500] // '#F3652B'
brandPrimitives.absolute.white // '#FFFFFF'

surfacePrimitives.surface[0] // '#FFFFFF'
surfacePrimitives.surface[950] // '#0A0A0A'

Available palettes: base, blue, gray, slate, orange, violet, yellow, green, red — plus the brand, surface, and alpha groups.

Motion primitives

import { curve, duration, animate } from '@aziontech/theme/animations'

curve['productive-exit'] // easing cubic-bezier
duration['fast-02'] // ms value
animate.shimmer // keyframe-backed animation definition

Text styles

import { textsData } from '@aziontech/theme/texts'

textsData['text-heading-2xl']
// { fontSize: { _: '1.875rem', sm: '3rem', md: '3.5rem' }, lineHeight: 1.25, fontWeight: 400 }

Responsive fontSize keys (_, sm, md, …) become @media (min-width: …) overrides in the compiled utilities.

Semantic variables as JS (Node / build steps / runtime)

import { compileThemeVars, compileThemeCss, injectThemeCss } from '@aziontech/theme/theme-colors'

compileThemeVars()
// → { light: { '--primary': '#F3652B', '--text-default': '#141414', … }, dark: { … } }

compileThemeCss()
// → ':root, [data-theme=light], .azion.azion-light { … }\n\n[data-theme=dark], .dark, … { … }'

injectThemeCss() // appends a <style data-azion-theme> element to <head>

Only useful when you can't precompile — production usage should prefer the static stylesheet.

CSS variables

The semantic layer flips automatically between modes:

:root,
[data-theme='light'],
.azion.azion-light {
  --primary: #f3652b;
  --text-default: #141414;
  /* … */
}

[data-theme='dark'],
.dark,
.azion.azion-dark {
  --text-default: #fafafa;
  /* … */
}

Use them directly:

.custom-component {
  color: var(--text-default);
  border-color: var(--primary);
}

Utility equivalents are generated in the same stylesheet (e.g. @utility text-default), so class="text-default" works wherever Tailwind runs.

Token resolution

Tokens use a reference system for maintainability:

// Define token reference
const textColor = tokenRef('primitives.gray.900')

// The compilers (scripts/compile-primitives.js, scripts/compile-theme.js)
// resolve refs to literal values at build time — and throw, listing every
// miss, if a ref does not resolve.
compileThemeVars()
// Output: { light: { '--text-default': '#141414', … }, dark: { … } }

The full reference — supported tokenRef prefixes, the build pipeline, how to add a token — lives in src/tokens/README.md.

Development

pnpm build:tokens # node src/scripts/build-tokens.mjs → dist/v4/globals.{css,scss}
pnpm build:dts    # vue-tsc --declaration (emit .d.ts next to sources)
pnpm format       # prettier over scripts/ and src/
pnpm pack:dry     # inspect the tarball contents

dist/ is committed, and prepack reruns build:tokens + build:dts — every publish rebuilds the artifact from source, so a stale or hand-edited dist/ can never ship.

Project structure

packages/theme/
├── tokens.js                    # in-repo JS barrel (not shipped — use the subpath exports)
├── src/
│   ├── tokens/
│   │   ├── primitives/          # colors (brand/surface/alpha), typography, shape, effects, animations, …
│   │   ├── semantic/            # texts/containers/spacings/z-indices data + semantic color refs
│   │   ├── theme/               # light/dark semantic groups (primary, background, text, ring, feedback/…)
│   │   └── README.md            # in-depth token documentation
│   └── scripts/
│       ├── refs.js              # tokenRef + isTokenRef + assertResolvedRefs
│       ├── compile-primitives.js
│       ├── compile-theme.js     # exported as ./theme-colors
│       └── build-tokens.mjs     # main entrypoint: emits dist/v4
├── dist/v4/globals.css          # the shipped stylesheet (committed; rebuilt on publish)
└── package.json

Browser support

Modern evergreen browsers with CSS custom-properties support (Chrome, Firefox, Safari, Edge).

Versioning

This package follows Semantic Versioning. Versions are managed by release-please: merges to main update a Release PR, and merging that Release PR cuts the version and publishes.

Contributing

This package is part of the Azion WebKit monorepo. Please see the main repository for contribution guidelines.

License

MIT © Azion Technologies

Changelog

See CHANGELOG.md for release history.

版本与发布记录

@aziontech/theme 共发布 47 个版本,首次发布于 2026/03/17;过去 12 个月发布了 47 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
5.2.2latest2026/11/044 天前
5.2.12026/10/2415 天前
5.2.02026/10/071 个月前
2.7.2legacy-v32026/09/261 个月前
2.7.12026/09/261 个月前
5.1.02026/09/241 个月前

关于 @aziontech/theme 的常见问题

@aziontech/theme 是什么?

Azion's design-token system, compiled into a single Tailwind CSS v4 stylesheet: primitive palettes, brand colors, light/dark semantic tokens, the full text-style scale, motion utilities and @keyframes, and the @font-face set — plus the raw token d

如何安装 @aziontech/theme?

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

@aziontech/theme 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/aziontech__theme 是否存在。

@aziontech/theme 支持 ESM 还是 CommonJS?

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

@aziontech/theme 可以商用吗?

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

@aziontech/theme 的下载量有多少?

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

@aziontech/theme 还在维护吗?

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