@allenai/varnish-theme

中文文档
3.0.12-alpha.0发布于 2026/04/23Apache-2.0TypeScriptESM + CJS零依赖近 30 天下载 2014

Theme and variables for AI2's Varnish

原始使用文档
文档目录9 节
  1. Using varnish-theme
  2. CSS
  3. JS
  4. JSON
  5. Simple Hex Unitless
  6. MUI Theme
  7. Development
  8. Adding Icons
  9. Updating Figma with varnish-theme tokens

varnish-theme

varnish-theme contains design tokens and basic CSS for AI2's varnish component library.

Using varnish-theme

First, install varnish-theme:

yarn add @allenai/varnish-theme

CSS

You can use the CSS tokens or varnish CSS by importing them into your CSS file by using CSS @import.

If you have the webpack css-loader set up, you can import them this way: For the tokens:

@import '~@allenai/varnish-theme/tokens.css' layer(varnish);

For the main CSS:

@import '~@allenai/varnish-theme/varnish.css' layer(varnish);

JS

We provide a typed JS file you can import.

import varnishTokens from '@allenai/varnish-theme';

JSON

We provide a JSON file similar to the JS file.

To import it in JS:

import varnishTokens from '@allenai/varnish-theme/tokens.json';

Simple Hex Unitless

If you want the theme with just the values, hexAlpha colors, and spacing tokens provided in pixels without a number, we provide that as well.

import simpleVarnishTokens from '@allenai/varnish-theme/simple-hex-unitless';

MUI Theme

If you're using MUI, varnish-theme provides a pre-built MUI theme integration:

import { varnishMuiTheme } from '@allenai/varnish-theme/mui';

Development

We use style-dictionary and style-dictionary-utils to create the exported files.

To add or change tokens, modify .js files in the tokens folder. To update the output with your new tokens, run yarn workspace @allenai/varnish-theme build.

Adding Icons

First, add your svg file under icons folder. Then update tokens/assets/icon.cjs with this filepath. Then run yarn workspace @allenai/varnish-theme build

Updating Figma with varnish-theme tokens

Further instructions here

  1. Go to your Figma document
  2. Click the Figma button in the top left corner. Go to plugins, and install Tokens Studio for Figma and open it
  3. Here you will see a visual representation of your tokens including colors, spacing, etc. Go to the tokens you want to edit and click the {} button in the top right.
  4. Here will be an editable JSON file of your tokens. Insert/edit your tokens here. You may need to format your new tokens to be in the same JSON style
  5. Click "Save JSON"
  6. Message your designer that you updated the tokens in Figma. Done!

版本与发布记录

@allenai/varnish-theme 共发布 40 个版本,首次发布于 2024/02/02;过去 12 个月发布了 4 个版本。

版本发布日期距今
3.0.12-alpha.0latest2026/04/236 个月前
3.0.11-alpha.02026/04/226 个月前
3.0.10-alpha.02026/04/156 个月前
3.0.9-alpha.02026/03/187 个月前
3.0.8-alpha.02025/10/251 年前
3.0.7-alpha.52025/10/251 年前

关于 @allenai/varnish-theme 的常见问题

@allenai/varnish-theme 是什么?

Theme and variables for AI2's Varnish

如何安装 @allenai/varnish-theme?

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

@allenai/varnish-theme 支持 TypeScript 吗?

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

@allenai/varnish-theme 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@allenai/varnish-theme 可以商用吗?

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

@allenai/varnish-theme 的下载量有多少?

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

@allenai/varnish-theme 还在维护吗?

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